emmanuel wrote:
Can you expand on your idea?
Well based on an earlier example in the thread:
Code:
@DeliveryMethod
class Delivery {
boolean receiveNews;
boolean phonePreferred;
@NotNull(groups={"byAddress"})
private String street;
@NotNull(groups={"byAddress"})
private String city;
@NotNull(groups={"byAddress"})
@Length(2)
private String state;
@NotNull(groups={"byAddress"})
@Max(99999)
@Min(0)
private Integer zip;
@NotNull(groups={"byPhone"})
@PhoneNumber
public String getTelephone() {
return telephone;
}
}
The DeliveryMethodValidator would expose any groups which should be used to validate the members of the class. This way, it can make high level business decisions, but the regular annotations could be used for the low level validation rules.
I also had a similar thought on leveraging groups in this way for "key" and "value" special groups, to allow validation of the individual elements of collections and maps.