JSR 303 Bean validation cheat sheet

This post is about a cheat sheet for quick a reference what annotation validation are available.

[one_half]
[googlefont font=”Courgette” fontsize=”25″]String[/googlefont]
@NotNull
@NotEmpty
@Email
@DecimalMax
@DecimalMin
@Range(min=?, max=?)
@Length(min=?, max=?)
@Size(min = ?, max = ?)
@Pattern(regex = ?, flag = ?)
@Digits(integer=?, fraction=?)
@Max
@Min
@Null
[/one_half]

[one_half_last]
[googlefont font=”Courgette” fontsize=”25″]Date, Calendar[/googlefont]
@Past
@Future
@NotNull
@NotEmpty
[/one_half_last]


[one_half]
[googlefont font=”Courgette” fontsize=”25″](Big)Integer[/googlefont]
@Min/(?)
@Max/(?)
@Range(min=?, max=?)
@Digits(integer=?, fraction=?)
[/one_half]

[one_half_last]
[googlefont font=”Courgette” fontsize=”25″](Big)Decimal[/googlefont]
@Min/(?)
@Max/(?)
@DecimalMax
@DecimalMin
@Range(min=?, max=?)
@Digits(integer=?, fraction=?)
[/one_half_last]

[one_half]
[googlefont font=”Courgette” fontsize=”25″]Object[/googlefont]
@NotNull
@Null
@NotEmpty
@Valid – Associated object get validate.
[/one_half]

[one_half_last]
[googlefont font=”Courgette” fontsize=”25″]Boolean[/googlefont]
@AssertFalse
@AssertTrue
[/one_half_last]


[one_half]
[googlefont font=”Courgette” fontsize=”25″]Byte, Short[/googlefont]
@Min/(?)
@Max/(?)
@Range(min=?, max=?)
@Digits(integer=?, fraction=?)
[/one_half]

[one_half_last]
[googlefont font=”Courgette” fontsize=”25″]Int, Long[/googlefont]
@Min/(?)
@Max/(?)
@Range(min=?, max=?)
@Digits(integer=?, fraction=?)
[/one_half_last]


[one_half]
[googlefont font=”Courgette” fontsize=”25″]Collection[/googlefont]
@Size(min=?, max=?)
[/one_half]

[one_half_last]
[googlefont font=”Courgette” fontsize=”25″]Others[/googlefont]
@CreditCardNumber
@Length(min=?, max=?)
@NotBlank
@Range(min=?, max=?)
@URL(protocol=?, host=?, port=?)
[/one_half_last]

 
[googlefont font=”Courgette” fontsize=”10″]

  1. http://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html_single/
  2. http://docs.jboss.org/hibernate/validator/4.1/reference/en-US/html/validator-usingvalidator.html
  3. http://beanvalidation.org/1.0/spec/

[/googlefont]
 

JSR 303 Bean validation cheat sheet

2 thoughts on “JSR 303 Bean validation cheat sheet

  • November 19, 2014 at 1:14 pm
    Permalink

    Very helpful cheat sheet. Thanks for sharing!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.