myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mynewsgro...@arcor.de
Subject ExtVal: Validating an objects attributes if at least one these has a value
Date Thu, 01 Jul 2010 14:08:37 GMT
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


Mime
View raw message