[hibernate-dev] Hibernate Validator: bean-level validation

Emmanuel Bernard emmanuel at hibernate.org
Thu Dec 6 11:31:28 EST 2007


Would that help
http://opensource.atlassian.com/projects/hibernate/browse/HV-22

a. can you expand your idea?
b. not sure why this is a problem, because you are not validating  
property 'name', you're validation 'name' and 'age' alltogether,  
hence there is no property name

On  Dec 6, 2007, at 10:47, Robert Spielmann wrote:

> Hi all,
>
> I ran into some sort of problem while trying to use Hibernate  
> Validator for context-based attribute validation. A property of the  
> bean only had to be present under certain circumstances. I found  
> two possible ways to deal with this:
>
> 1. Validate the aforementioned property using something other than  
> Hibernate Validator because annotation parameters must be constant  
> at compile time and cannot be set at runtime,
> 2. Write my own bean-level validator in order to get access to the  
> entire bean, which brings in a problem with the InvalidValue array:  
> for bean-level annotations, the returned property name is null. As  
> soon as you have more than one bean-level annotation, you cannot  
> distinguish between the fields the annotation(s) tried to validate.
>
> It would be very nice if I could:
>
> a) Pass parameters to the validator at runtime or
> b) return a not-null property name for bean-level validation.
>
> Hope that I haven't missed a way which solves this problem; I'd  
> like very much to hear about your opinions on this.
>
> Mit freundlichen Grüßen / Best regards
>
> Robert Spielmann
> IT Consultant
>
> -- 
>
> codecentric GmbH
> Grünewalder Str. 29-31
> 42657 Solingen
>
> Telefon +49 (212) 2494-322
> Fax +49 (212) 2494-334
> Mobil +49 (151) 14705709
>
> E-Mail spielmann at codecentric.de
>
> Internet www.codecentric.de <http://www.codecentric.de/>
>
> Geschäftsführer: Peter Gierse, Mirko Novakovic und Rainer Vehns
> Sitz der Gesellschaft: Solingen
>
> Registergericht: Amtsgericht Wuppertal, HRB 19214
>
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev





More information about the hibernate-dev mailing list