Skip to content

This is a custom validator based on Jakarta validation-api, inspired by org.hibernate.validator.constraints.ScriptAssert.

License

Notifications You must be signed in to change notification settings

ro4/spel-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpEL Validation

Scrutinizer Code Quality Code Coverage Build Status

This is a custom validator based on Jakarta validation-api, inspired by org.hibernate.validator.constraints.ScriptAssert.

The source code is so tiny, you can read it as document :)

Example

@SpELAssert("#p.maxAge > 100") // repeatable annotation
@SpELAssert(expression = "#_.maxAge > 100", alias = "_") // alias support
@SpELAssert(
        expression = {"#p.minAge < #p.maxAge", "and #p.minAge > 10"}, // multi-line expressions
        message = "Max must greater than min age, min age must greater than 10",
        reportOn = "minAge"
)
public class Config {

    @SpELAssert("@springBean.method(#p)") // spring bean invoke
    private String name;

    private Integer minAge;

    private Integer maxAge;
}

About

This is a custom validator based on Jakarta validation-api, inspired by org.hibernate.validator.constraints.ScriptAssert.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages