[bv-dev] Creating custom nodes in cross-parameter constraint validators

Emmanuel Bernard emmanuel at hibernate.org
Tue Feb 19 08:04:08 EST 2013


It looks like it's the right way to go. We will also need to retrofit
the bean-level case. In that situation, we will need to inherit the
inIterable, key and index values of the node being suppressed.

https://gist.github.com/emmanuelbernard/f73bff117cff8195e41f

I will try and do a write up for the spec.

https://hibernate.onjira.com/browse/BVAL-410

Emmanuel

On Tue 2013-02-19 13:00, Gunnar Morling wrote:
> Hi,
> 
> We added the method addParameterNode() to the node builder API, allowing
> for the creation of custom subpaths in cross-parameter constraint
> validators.
> 
> Currently such a path will look like this (the first two nodes are the
> default ones, the remain ones are custom created nodes):
> 
> METHOD -> CROSS_PARAMETER -> PARAMETER -> ...
> 
> I'm wondering whether it wouldn't be better to get rid of the
> cross-parameter node in this case:
> 
> METHOD -> PARAMETER -> ...
> 
> E.g. when looking at the following example:
> 
>     @OldAndNewPasswordDifferent
>     public void resetPassword(String new, String old) { ... }
> 
> Then I think the following path might be what constraint authors want:
> 
> MethodNode("resetPassword") -> ParameterNode("old", arg1)
> 
> As it seems, the RI does the same when custom nodes are added in
> class-level constraint validators (i.e. no node for the class-level
> constraint will be part of the path). Shortly looking in the spec, I
> couldn't find an example mandating this behavior, though.
> 
> Any thoughts?
> 
> --Gunnar

> _______________________________________________
> 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