Bean Validation Made Simple With JSR 303 | Javalobby
Travel of Software Developer: JSR 303 Bean Validation
Bean Validation: Integrating JSR-303 with Spring « Dutchworks Blog / Dutchworks: Enterprise Java, Open Source, software solutions, Amsterdam
5. Validation, Data Binding, and Type Conversion
Travel of Software Developer: JSR 303 Bean Validation
Bean Validation: Integrating JSR-303 with Spring « Dutchworks Blog / Dutchworks: Enterprise Java, Open Source, software solutions, Amsterdam
5. Validation, Data Binding, and Type Conversion
JSR 303
This JSR will define a meta-data model and API for JavaBeanTM validation based on annotations, with overrides and extended meta-data through the use of XML validation descriptors.
- XWork Validation Framework (http://wiki.opensymphony.com/display/XW/Validation+Framework)
- Commons-Validator (http://jakarta.apache.org/commons/validator/)
- Hibernate Validator (http://www.hibernate.org/hib_docs/annotations/reference/en/html/validator.html)
- JSR 303 provides an easy way of ensuring that the properties of your JavaBean(s) have the right values in them.
- Pre-JSR 303
- You probably would have needed a bunch of if-else statements to achieve the above requirements.
- The next step is to download an implementation of JSR 303.
- Hibernate Validator 4.2.0 Final
- hibernate-validator-4.2.0.Final.jar
- hibernate-validator-annotation-processor-4.2.0.Final.jar
- slf4j-api-1.6.1.jar
- validation-api-1.0.0.GA.jar
- Simply annotate the 'Member' JavaBean we created earlier to indicate which properties need be validated.
- @NotNull
- @NotBlank
- @Pattern
- @Past
- @Min
- @Max
- Unit Test
- ValidatorFactory
- Validator
- violation
No comments:
Post a Comment