Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate validator NotEmpty trim issue

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?

like image 514
Marcus Leon Avatar asked Jan 15 '10 17:01

Marcus Leon


1 Answers

@NotEmpty is used to check size rather than contents and applies to Collections as well as Strings. The functionality you're looking for is provided in @NotBlank which is specific to Strings and ignores trailing whitespace.

like image 71
Ken Blair Avatar answered Sep 21 '22 16:09

Ken Blair