I'm trying to validate some fields before persisting them to the database. In particular, I need to know that a String contains a non-whitespace character.
I'm using the javax.validation.constraints.Pattern
annotation, as follows:
@Pattern(regexp = "[^\\s]")
private String field;
This seems to throw the ConstraintViolation on every String. What am I missing?