You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2015/03/06 13:41:16 UTC
svn commit: r1664603 -
/sling/site/trunk/content/documentation/bundles/validation.mdtext
Author: kwin
Date: Fri Mar 6 12:41:15 2015
New Revision: 1664603
URL: http://svn.apache.org/r1664603
Log:
SLING-4387 document validation of sub resources
Modified:
sling/site/trunk/content/documentation/bundles/validation.mdtext
Modified: sling/site/trunk/content/documentation/bundles/validation.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/validation.mdtext?rev=1664603&r1=1664602&r2=1664603&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/bundles/validation.mdtext (original)
+++ sling/site/trunk/content/documentation/bundles/validation.mdtext Fri Mar 6 12:41:15 2015
@@ -24,6 +24,20 @@ To validate a resource one first needs t
// give out error message that the validation model is invalid!
}
+Apart from that it is also possible to validate resources including all child resources having their own validation model (i.e. a merged view of the validation models is applied). The appropriate validation model is being looked up by getting the resource type for each node. Since by default the JCR will return the primary type in case there is no `sling:resourceType` property found on the node, either the 2nd parameter `enforceValidation` should be set to `false` or some resource types must be explicitly ignored to also properly support validation models which have children on its own.
+
+ ::java
+ try {
+ ValidationResult result = validationService.validateAllResourceTypesInResource(resource, false, null);
+ if (!result.isValid()) {
+ // give out validation messages from result.get
+ }
+
+ } catch (IllegalStateException e) {
+ // give out error message that an invalid validation model for at least one sub resource was found
+ } catch (IllegalArgumentException e) {
+ // one of the resource types is absolute or there was no validation model found for at least one sub resource
+ }
# Validation Model Resources
The `ValidationModel` is constructed from resources with the resourceType **sling/validation/model**. Those resources are considered validation model resources if they are located