In addition to providing standard validators for our use, JSF allows us to create custom validators. This can be done in one of two ways—by creating a custom validator class or by adding validation methods to our named beans.
Custom data validation
Creating custom validators
In addition to the standard validators, JSF allows us to create custom validators by creating a Java class implementing the javax.faces.validator.Validator interface.
The following class implements an email validator, which we will use to validate the email text input field in our customer data entry screen:
package net.ensode.glassfishbook.jsfcustomval; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; ...