Hi at all,
I have the following use case simplified with an object 'Address' including
zip, city and so on using BeanValidation:
public class Address {
@NotNull(Create.class)
@Size(min=3, max=10)
private String zip;
@NotNull
@Size(min=3, max=50)
private String city;
...
}
This class should be used in two pages: for creating an address (both
attributes need to be set, group=Create) and to find an address (city is
sufficient for searching, group=default).
In addition I want to reuse the address definition in pages to submit or search
an order with both a home address and an optional invoice address. The problem
is: if no value is entered into the fields for the invoice address, it should
not be validated at all. If at least one field is filled, all constraints have
to be validated, additionally considering groups to be used.
I think with bean validation only this is not possible, that's why I guess I
have to use ExtVal again but don't know where to start. A custom validation
strategy would be a choice, perhaps @SkipValidation offers another way to go?
Or can it be done even easier (settings remain unchanged: single class as
central point for validation rules which is reusabe in different use cases,
validation should take place in validation phase)?
Can you give me some advice where to start?
Thanks,
Tom
--
Hotelbewertung: Bloß nicht die Katze im Sack kaufen bzw. den Floh auf der
Matratze buchen -
ob geschäftlich oder privat - erst das Hotel im Reise-Channel auf arcor.de
checken!
http://www.arcor.de/rd/footer.hotel