JavaBean Validation declares integrity rules on domain-model properties and makes them reusable across application layers. Annotations express constraints such as non-null values, string length, regular-expression patterns, and numeric or date ranges instead of repeated conditional checks. The same rules can support presentation and persistence validation, while the SQL database remains the final validator of durable data. section 3.3 section 3.3.2
Use the API to:
- Declare constraints directly on Java fields or other model elements using validation annotations. section 3.3
- Expose property paths and localized or customized messages for failed constraints. section 3.3.2
- Integrate validation automatically with JPA persistence providers when constrained persistent data is stored. section 3.0
Constraining an auction item
An Item can require a non-null name containing 2–255 characters and require auctionEnd to be in the future. Creating a Validator and validating an instance returns ConstraintViolation objects; an auctionEnd set to the current date produces a violation whose property path is auctionEnd.

