• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validate two propertis with only one custom validator

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic