I would like to show unique error numbers alongside the error message and resolve these numbers with a simple mechanism that can be used for for javax.validation annotations and custom validators.
For annotated model classes I would like to use the default message parameter:
For the more complicated validation, I am using Spring validation classes:Code:@Pattern(regexp = "[A-Z0-9]{2}[A-Z]?", message = "err-332") private String specialField;
Code:if (!condition) { errors.reject("err-442"); }
The standard validation mechanisms as used in Spring generates error codes from the rejected values. For the annotated fields this would follow the order as documented in Resolving codes to error messages and generate several error codes containing constraint, bean name, field name and field type.
I would like to use the default message from the constraint for the validator.
From the source code I can see that the DataBinder initializes the binding result (method initBeanPropertyAccess). How can I use a custom BeanPropertyBindingResult that behaves accordingly on reject?
Thank you,
Kariem


Reply With Quote
