Gunnar Morling Open source software engineer at Red Hat Hibernate Debezium Spec Lead for Bean Validation 2.0 Other projects: ModiTect, MapStruct [email protected] @gunnarmorling http://in.relation.to/gunnar-morling/ 3
What is Bean Validation? "Constraint once, validate everywhere" Constraints for JavaBeans Validation via API or automatically JPA JSF, Spring MVC, GWT JAX-RS Extensible (custom constraints) BV 1.1: method validation 4
Use Case: Different Passwords for Different Roles @Size.List({ @Size(min = 8, group = Default.class), @Size(min = 12, group = Admin.class) }) private char[] password = ...; 7
Use Case: Ensure Non-Empty Collection Elements private List names; private List<@NotEmpty String> names; @OnElements(constraint=@NotEmpty) private List names; 12
Use Case: Ensure Non-Empty Collection Elements private List names; private List<@NotEmpty @Pattern(regexp="[a-zA-Z]*") String> names; @OnElements(constraint=@NotEmpty) private List names; 13
Use Case: Delivery Date in the Future @Past/@Future supported for JSR 310 types: java.time.LocalDateTime, ZonedDateTime etc. @Future private LocalDate deliveryDate = LocalDate.of( 2017, Month.MAY, 12 ); 25
Next Steps Proposed Final Draft this week Reference implementation: Hibernate Validator 6.0 Beta2 Your feedback is needed :-) Part of Java EE 8 (July 2017) 31