Search in sources :

Example 1 with CustomValidatorBean

use of org.springframework.validation.beanvalidation.CustomValidatorBean in project yyl_example by Relucent.

the class CustomValidatorExample method main.

public static void main(String[] args) {
    CustomValidatorBean validator = new CustomValidatorBean();
    validator.afterPropertiesSet();
    Sample sample = new Sample();
    Errors errors = new MapBindingResult(new HashMap<>(), Sample.class.getName());
    validator.validate(sample, errors);
    for (ObjectError error : errors.getAllErrors()) {
        System.out.println(error.getDefaultMessage());
    }
}
Also used : Errors(org.springframework.validation.Errors) ObjectError(org.springframework.validation.ObjectError) CustomValidatorBean(org.springframework.validation.beanvalidation.CustomValidatorBean) MapBindingResult(org.springframework.validation.MapBindingResult)

Aggregations

Errors (org.springframework.validation.Errors)1 MapBindingResult (org.springframework.validation.MapBindingResult)1 ObjectError (org.springframework.validation.ObjectError)1 CustomValidatorBean (org.springframework.validation.beanvalidation.CustomValidatorBean)1