JavaBeans Validation: Difference between revisions
Jump to navigation
Jump to search
(10 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
=Overview= | =Overview= | ||
* Bean Validation 1.0 JSR 303 https://jcp.org/en/jsr/detail?id=303 | * Bean Validation 1.0 JSR-303 https://jcp.org/en/jsr/detail?id=303 | ||
* Bean Validation 1.1 JSR 349 https://jcp.org/en/jsr/detail?id=349 | * Bean Validation 1.1 JSR-349 https://jcp.org/en/jsr/detail?id=349 | ||
=Dependencies= | |||
<syntaxhighlight lang='xml'> | |||
<dependency> | |||
<groupId>javax.validation</groupId> | |||
<artifactId>validation-api</artifactId> | |||
<version>2.0.1.Final</version> | |||
</dependency> | |||
</syntaxhighlight> | |||
=Concepts= | |||
==Validation Provider== | |||
==Expression Support== | |||
=Annotations= | =Annotations= | ||
Line 15: | Line 31: | ||
* [[@Valid]] | * [[@Valid]] | ||
==Constraints== | ==<span id='Constraints'></span>Built-in Constraint Annotations== | ||
* [[@AssertFalse]] | |||
* [[@AssertTrue]] | |||
* [[@DecimalMax]] | |||
* [[@DecimalMin]] | |||
* [[@Digits]] | |||
* [[@Future]] | |||
* [[@Max]] | |||
* [[@Min]] | |||
* [[@NotNull]] | * [[@NotNull]] | ||
* [[@Null]] | |||
* [[@Past]] | |||
* [[@Pattern]] | |||
* [[@Size]] | * [[@Size]] | ||
* [[@NotBlank]] | * [[@NotBlank]] | ||
==Custom Annotations== | |||
JavaBeans Validation supports custom annotation constraints, which require a custom implementation class. | |||
=Hibernate Validator= | =Hibernate Validator= | ||
Line 27: | Line 56: | ||
Hibernate Validator is a JSR-303 and JSR-349 provider. | Hibernate Validator is a JSR-303 and JSR-349 provider. | ||
==Hibernate Validation | ==<span id='Hibernate_Validation_Extensions'></span>Hibernate Validation Annotations== | ||
* [[Hibernate @NotBlank|@NotBlank]] | * [[Hibernate @NotBlank|@NotBlank]] | ||
* [[@CreditCardNumber]] | * [[@CreditCardNumber]] | ||
=Generic JavaBeans Validation Example= | |||
{{Internal|Generic JavaBeans Validation|Generic JavaBeans Validation Example}} |
Latest revision as of 23:03, 25 October 2018
External
Internal
Overview
- Bean Validation 1.0 JSR-303 https://jcp.org/en/jsr/detail?id=303
- Bean Validation 1.1 JSR-349 https://jcp.org/en/jsr/detail?id=349
Dependencies
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
Concepts
Validation Provider
Expression Support
Annotations
Built-in Constraint Annotations
- @AssertFalse
- @AssertTrue
- @DecimalMax
- @DecimalMin
- @Digits
- @Future
- @Max
- @Min
- @NotNull
- @Null
- @Past
- @Pattern
- @Size
- @NotBlank
Custom Annotations
JavaBeans Validation supports custom annotation constraints, which require a custom implementation class.
Hibernate Validator
Hibernate Validator is a JSR-303 and JSR-349 provider.