Custom data validation
In addition to providing standard validators for our use, Jakarta Faces 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.
Creating custom validators
In addition to the standard validators, Jakarta Faces allows us to create custom validators by creating a Java class implementing the jakarta.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 com.ensode.jakartaeebook.facescustomval; //imports ommitted for brevity @FacesValidator(value = "emailValidator") public class EmailAddressValidator implements Validator { @Override public void validate(FacesContext facesContext, UIComponent uiComponent, ...