close

Filter

loading table of contents...

Content Application Developer Manual / Version 2204

Table Of Contents
4.3.6.3.1 Validators

In 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.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.