If this validation only occurs in a single page, then you may consider using validation inside the page-managed bean. However, if you want this validation to be used in different components or in different pages, consider creating a JSF validator.
In this recipe, we will create a custom validator for the employee's
CreateCustomJSFValidator application from the Git repository.
In order to create custom JSF validator, we need to perform the following steps:
Create a class that implements the
Register this class as a validator inside the
Apply the validator on input components.