It appears that the Hibernate NotEmpty
annotation does not result in an error for strings filled with whitespace (" "
). Only works for nulls or empty strings (ie: new String()
). Is there a workaround/fix for this?
views:
289answers:
2
+2
A:
Replace your @NotEmpty with a @Pattern annotation that includes a regex expression that will fail on strings that are pure whitespace or empty (you may be able to include both @NotEmpty and @Pattern and simplify the regex that way). Or write a custom validator as described here.
Jherico
2010-01-15 18:11:36
Thanks, I ended up writing a custom validator.
Marcus
2010-01-15 19:04:15