Hi Bertrand,
1. Currently there's no support for hierarchical structures. ValueMap
doesn't provide this kind of support. I see two solutions here (the first
is your idea from the private chat we had earlier):
a. create a HierarchicalValueMap and perform validation on top of this;
this also implies that we change the SlingHttpServletRequestAF to create
HierarchicalValueMap adapters;
b. bake this only in the implementation of the ValidationService - have
it transform path-like property names into hierarchical structures for
validation
The hierarchical structures validation should also be reflected on the way
the Fields are defined - initially I considered that Fields are mapped 1:1
to a resource's property.
2. As long as the Field from the ValidationModel specifies a certain
Validator to be used for validating the field's value I don't see why we
couldn't have a Validator that checks the data in an external system. The
single current constraint of a Validator is that it has to provide a
validate method, returning a boolean. The implementation can be done
however the developer sees fit.
I hope this helps.
Regards,
Radu
On Wed, Jul 3, 2013 at 5:08 PM, Bertrand Delacretaz
<[email protected]>wrote:
> Hi Radu,
>
> I've briefly reviewed your SLING-2803 code and it looks quite good to me!
>
> I'm wondering if it supports the following use cases:
>
> 1) Validating hierarchical structures
> Say I'm POSTing a small tree of resources rooted at /foo, can you
> validate for example that /foo/customer/email is present and valid
> according to an email validator?
>
> How about validating any property named "email" found somewhere within
> that posted tree?
>
> 2) Extensible types
> In the above example, can you also validate that the specified email
> is present in an external system, to which a custom OSGi service
> provides access?
>
> We might not need these features immediately, but IMO they should at
> least be supported at the API/code design level.
>
> -Bertrand
>