7

I decided to use JSR303 to validate my forms in Spring 3.0 MVC application. When I try to check @NotEmpty on Integer variable I have exception:

javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.Integer

First this variable was declared as int (protected int partCount) but I found on the Spring forum that primitives may cause some problems, so I've changed that to Integer. Still same exception. Any ideas?

PS. Same situation with Double and Timestamp, no problems with Strings

Thanks

Lion
  • 18,729
  • 22
  • 80
  • 110
Marek
  • 457
  • 8
  • 17

1 Answers1

10

Not sure what implementation you're using but here is what Hibernate Validator writes about the NotEmpty annotation (which is not part of the Bean Validation specification):

Check that a String is not empty (not null and length > 0) or that a Collection (or array) is not empty (not null and length > 0)

Maybe you're looking for something else? Like NotNull, or Min?

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Thanks, ill check that soon and let u know if NotNull will give proper results :) – Marek Sep 21 '10 at 15:26
  • Its ok now. Thanks for your help, i should check api manual before asking stupid questions like this :) – Marek Sep 21 '10 at 15:31