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 2014/11/27 16:15:47 UTC
svn commit: r1642173 -
/sling/site/trunk/content/documentation/bundles/validation.mdtext
Author: kwin
Date: Thu Nov 27 15:15:47 2014
New Revision: 1642173
URL: http://svn.apache.org/r1642173
Log:
SLING-4011 document changes for pattern matching of properties and childresources
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=1642173&r1=1642172&r2=1642173&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/bundles/validation.mdtext (original)
+++ sling/site/trunk/content/documentation/bundles/validation.mdtext Thu Nov 27 15:15:47 2014
@@ -33,13 +33,15 @@ The resources should have the following
-------------------- | ------- | -------------- | -------------| ---------
`sling:resourceType` | Property | `String` | Always `sling/validation/model`, otherwise node will never be picked up by Sling Validation. | yes | `sling/validation/model`
`validatedResourceType` | Property | `String` | The resource type of the resource for which this validation model should be applied. | yes | `my/own/resourcetype`
-`applicablePaths` | Property | `String[]` | Path prefixes which restrict the validation model to resources which are below one of the given prefix. No wildcards are supported. If not given, there is not path restriction. | no | `/content/mysite`
-`properties\<propertyName>` | Resource | - | This resource ensures that the property with the name `<propertyName>` is there. | no | `false`
-`properties\<propertyName>\propertyMultiple` | Property | `Boolean` | If `true` only multivalue properties are allowed with the name `<propertyName>`. If not set or `false`, multi- and single-value properties are accepted. | no | `false`
+`applicablePaths` | Property | `String[]` | Path prefixes which restrict the validation model to resources which are below one of the given prefixes. No wildcards are supported. If not given, there is not path restriction. | no | `/content/mysite`
+`properties\<propertyName>` | Resource | - | This resource ensures that the property with the name `<propertyName>` is there. The resource name has no longer a meaning if the property `nameRegex` is set on this node. | no | `false`
+`properties\<propertyName>\propertyMultiple` | Property | `Boolean` | If `true` only multivalue properties are allowed with the name `<propertyName>` or matching the `nameRegex`. If not set or `false`, multi- and single-value properties are accepted. | no | `false`
+`properties\<propertyName>\nameRegex` | Property | `String` | If set the `<propertyName>` has no longer a meaning. Rather all properties which match the given regular expression are considered. At least one match is required, otherwise the validated resource/valuemap is considered invalid. | no | `property[0-8]`
`properties\<propertyName>\validators\<validatorName>` | Resource | - | The `<validatorName>` must be the OSGi component name of a validator. Each validators node might have arbitrarily many subnodes (one per validator). | no | `false`
-`properties\<propertyName>\validators\<validatorName>\validatorArguments` | Property | `String[]` | The parametrization for the validator with the name `<validatorName>`. Each value must have the pattern `key=value`. | no | `regex=^[a-z]*$`
-`children\<resourceName>` | Resource | - | This resource ensures that the resource with the name `<resourceName>` is there. | no | `child1`
-`children\<resourceName>\properties\<propertyName>` | Resource | - | This resource ensures that the property with the name `<propertyName>` is there below the resource with the name `<resourceName>`. Below this node validators can be given like for properties on the root level. | no | `property1`
+`properties\<propertyName>\validators\<validatorName>\validatorArguments` | Property | `String[]` | The parametrization for the validator with the name `<validatorName>`. Each value must have the pattern `key=value`. The parametrization differs per validator. | no | `regex=^[a-z]*$`
+`children\<resourceName>` | Resource | - | This resource ensures that the resource with the name `<resourceName>` is there. The resource name has no longer a meaning if the property `nameRegex` is set on this node. | no | `child1`
+`children\<resourceName>\nameRegex` | Property | `String` | If set the `<resourceName>` has no longer a meaning. Rather all resources whose name match the given regular expression are considered. At least one match is required, otherwise the validated resource/valuemap is considered invalid. | no | `child[1-9]`
+`children\<resourceName>\properties` | Resource | - | The properties can be configured on the child level in the same way as on the root level. | no | -
# Usage in Sling Models
@@ -72,7 +74,7 @@ The Sling validation bundle currently co
To write a validator one needs to implement the `Validator` interface in an OSGi service.
That interface defines the method `validate`. That is called for each property which is bound to the validator through the Validation Resources.
-Each validator needs to specify one type parameter which defines upon which classes the validator can act (usually `String`). If a property value cannot be converted to the requested type from the validator (through `ValueMap.get(name, type)`), validation will fail.
+Each validator needs to specify one type parameter which defines upon which classes the validator can act (usually `String`). Array types are also supported here. Collection types are not supported. If a property value cannot be converted to the requested type from the validator (through `ValueMap.get(name, type)`), validation will fail.
# References