Content Application Developer Manual / Version 2207
Table Of ContentsIn order to validate a form, an org.springframework.validation.Validator can be implemented for arbitrary form backing beans. The validation method populates an org.springframework.validation.Errors object with error messages, see MyFormValidator Example for a complete example.
if(form.getEmail() == null) { errors.rejectValue( "email", "error-email-missing", "The email address is missing." ); }
The first argument passed to Errors#rejectValue()
denotes the form bean
property (here: “email”) that is invalid. The following arguments are an error code (to
be defined in a resource bundle) and a default message.
Global errors affecting the entire form instead of a single property are supported, too.