Bean Validation 2.0

Java EE 8 updates the Bean Validation version to 2.0. Besides including new, pre-defined constraints, it mainly targets support for Java SE 8.

The Java SE 8 support includes multiple, differently-configured validation constraint annotations. Types of the Java 8 Date and Time API are now supported; for example, via usage such as @Past LocalDate date.

Values that are contained in container types can also be validated separately, via parameterized type annotations. Examples for this are Map<String, @Valid Customer> customers, List<@NotNull String> strings, and Optional<@NotNull String> getResult().

Bean Validation 2.0 includes new pre-defined constraints. For example, @Email validates email addresses. @Negative and @Positive verify numeric values. @NotEmpty ensures that collections, maps, arrays, or strings are not empty or null. @NotBlank validates that strings do not solely consist of whitespace.

These constraints are a helpful default feature that avoids potentially defining this manually.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.165.70