There are two types of input validation you must consider in any application: syntactic and semantic validation. A form field value that represents a date, for instance, must be written in a certain format (i.e., be syntactically correct) in order to be interpreted by the application. It may also have to follow other rules (i.e., be semantically correct) to be accepted, e.g., be a date in the future or later than another date.
In JSF, components perform syntactic validation typically during the conversion from a request parameter string value to the native type of the business data property bound to the component. For semantic validation, you can attach validators to the components. JSF comes with a set of standard validators for the most common validation needs and lets you develop custom validators for more complex rules. We’ll look at both alternatives in this chapter.