File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validate two propertis with only one custom validator

 
gianluca gian
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello, I have a problem with validation. Is it possible to validate two properties of a bean using only one ConstraintValidator? I have something like the following:


inside the CheckSomeBeanPropertiesValidator I call the service SomeApplicationService that returns some data searched calling findBySearchBean. Instead to have to call more than one customized ConstraintValidator (and more than one findBySearchBean) is it possible to call only one time the service and check two different properties?

Thanks

bye
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code it makes it easier to read. I have added them for you so you can see the difference it makes.

It looks like your question is how to create an annotation that allows you to validate multiple fields. There is a good explanation of that here:
http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303
 
gianluca gian
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes in that way source code is much better. I will read what you suggested me soon, I think it's right what I was looking for. Thank you. Bye
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic