[bv-dev] Legal to validate constraints more than once?

Emmanuel Bernard emmanuel at hibernate.org
Mon Jan 21 11:19:25 EST 2013


The text in 4.6.1 is here to guaranty determinability in how constraint
violations are returned in a complex object graph. I imagine that
technically we can ensure that:

- a constraint is only validated once in a graph
- a constraint violation is reported several times if the violating
  instance is found several times in different navigation path

But the spirit of the spec is slightly more loose. Check bullet points
in 4.6:

> execute all [...] validations [...] matching the targeted group unless
> the given validation constraint has already been processed during this
> validation routine for a given navigation path [...] as part of a previous
> group match

So the note is an oversimplification and we should probably remove it

> Note that this implies that a given validation constraint will not be
> processed more than once per validation.

Emmanuel

On Mon 2013-01-21 17:03, Gunnar Morling wrote:
> 2013/1/21 Matt Benson <mbenson at apache.org>
> 
> >
> > On Mon, Jan 21, 2013 at 9:17 AM, Hardy Ferentschik <hardy at hibernate.org>wrote:
> >
> >> On 21 Jan 2013, at 3:36 PM, Gunnar Morling <gunnar at hibernate.org> wrote:
> >>
> >> > I'm wondering whether it's legal that one constraint gets validated
> >> more than once during one validation operation. The spec seems a bit
> >> contradictory in this regard.
> >> >
> >> > In section 4.6 "Validation routine" [1] it says:
> >> >
> >> > "[...] this implies that a given validation constraint will not be
> >> processed more than once per validation."
> >> >
> >> > Section 4.6.1 "Object graph validation" says though:
> >> >
> >> > "[...] object graph navigation can lead to multiple validations of the
> >> same constraint and the same object instance but the set of constraint
> >> validation is deterministic and the algorithm prevents infinite loops."
> >> >
> >> > What is right here? Or is this to say that *only* during graph
> >> validation a constraint may be validated multiple times but not e.g. during
> >> validation of multiple groups, all of which a constraint is part of?
> >>
> >> If you are just validating a single bean every constraint can only be
> >> validated once. However, when you are dealing with object graphs a
> >> constraint can be validated once per path on which you reach it.
> >> So both sentences make sense in their context, but taken together there
> >> seems to be a contradiction. Maybe the first statement could just be
> >> removed?
> >>
> >>
> > My read of these sections yields an understanding that, during any
> > validation call, the same validated object/constraint pair must be
> > evaluated only once.  I seem to be in agreement with Hardy here.
> >
> 
> I'm confused, you say each object/constraint may only be validated once,
> while Hardy said that during graph validation the same object/constraint
> actually may be validated several times. So did you want to say you
> *dis*agree with what Hardy said?
> 
> --Gunnar
> 
> 
> >
> >
> > Matt
> >
> >
> >> --Hardy
> >>
> >>
> >>
> >> _______________________________________________
> >> beanvalidation-dev mailing list
> >> beanvalidation-dev at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
> >>
> >
> >
> > _______________________________________________
> > beanvalidation-dev mailing list
> > beanvalidation-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
> >
> >

> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev



More information about the beanvalidation-dev mailing list