Hibernate Validation

Here’s a list of annotations that you can use to validate java beans:

  • @Length(min=, max=) Checks whether the string length matches the range
  • @Max(value=) Checks that the value is less than or equal to the max
  • @Min(value=) Checks that the value is greater than or equal to the min
  • @NotNull Checks that the value is not null
  • @Past For a date object, checks that the date is in the past
  • @Future For a date object, checks that the date is in the future
  • @Pattern(regex=”regexp”, flag=) For a string, checks that the string matches this pattern
  • @Range(min=, max=) Checks whether the value is between the min and the max
  • @Size(min=, max=) For collections, checks that the size is between the two
  • @AssertFalse Asserts that the evaluation of the method is false
  • @AssertTrue Asserts that the evaluation of the method is true
  • @Valid For a collection or a map, checks that all the objects they contain are valid
  • @Email Checks whether the string conforms to the email address specification

From Depressed Programmer.