[bv-dev] Is it allowed to validate complete paths using Validator#validateProperty()

Matt Benson mbenson at apache.org
Fri Jun 1 13:15:10 EDT 2012


Actually... ;)

Going back to the spec now I can see how you arrived at your
conclusion, Gunnar.  Specifically the spec says "JavaBeans property
name (as defined by the JavaBeans Introspector class)."  I consider
validating an entire property path to be a perfectly valid use case
and would support expanding the definition of the propertyName
parameter of #validateProperty() and #validateValue() to an expression
compatible with the Path interface.

Further, I would suggest making some gesture toward providing
overloaded forms of these methods that took Path objects explicitly,
perhaps even as an alternative to requiring that an implementation
support @propertyName-as-expression.

Matt

On Fri, Jun 1, 2012 at 12:09 PM, Matt Benson <mbenson at apache.org> wrote:
> It is my understanding that any path expression should be supported;
> this is certainly how Apache BVal operates.  Note that validations are
> still not cascaded, although Apache BVal provides a special
> implementation-specific interface that permits this.
>
> Matt
>
> On Fri, Jun 1, 2012 at 12:03 PM, Gunnar Morling <gunnar at hibernate.org> wrote:
>> Hi,
>>
>> I just stumbled upon a question on SO [1], which basically is about
>> whether it's allowed to pass a complete property path (e.g.
>> "foos[1].bar") to Validator#validateProperty(), or whether only single
>> properties (e.g. "foos") can be validated using that method.
>>
>> Based on a quick look into the API doc and the spec, I'd say only
>> single properties are supported here right now (the doc of the
>> parameter "propertyName" describes it as "property to validate"), but
>> I'm not really sure. WDYT?
>>
>> If this is not supported as of BV 1.0, do you think it should be in 1.1?
>>
>> --Gunnar
>>
>> [1] http://stackoverflow.com/questions/10835595/hibernate-validator-calling-validatepropertyobject-list0-field1-groups-o
>> _______________________________________________
>> 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