aspose file tools
The moose likes Validation -JSR303 and the fly likes validate two propertis with only one custom validator Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java JSRs » Validation -JSR303
Reply Bookmark "validate two propertis with only one custom validator" Watch "validate two propertis with only one custom validator" New topic
Author

validate two propertis with only one custom validator

gianluca gian
Greenhorn

Joined: Aug 14, 2009
Posts: 27
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

Joined: Mar 07, 2010
Posts: 1282

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


[How To Ask Questions][Read before you PM me]
gianluca gian
Greenhorn

Joined: Aug 14, 2009
Posts: 27
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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: validate two propertis with only one custom validator
 
Similar Threads
validLetters()
Custom Bean Validator Not Called
Properties/Settings - a design question
Inheritance / Komposition of multiple abstract classes
Go/Label makes code Readable, if if else else makes unreadable