You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Karolis Mackevicius (JIRA)" <ji...@apache.org> on 2017/05/17 16:34:04 UTC

[jira] [Commented] (SLING-6516) ValidationModelProvider evaluating additional annotations on a Sling Model bound to a specific resource type

    [ https://issues.apache.org/jira/browse/SLING-6516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16014356#comment-16014356 ] 

Karolis Mackevicius commented on SLING-6516:
--------------------------------------------

Pull Request Implementation details.
|| Property/Resource in Resource-based validation model||	Equivalent in Annotation-based validation model || Example ||
| validatedResourceType	| resourceType element in @Model annotation, https://sling.apache.org/documentation/bundles/models.html#associating-a-model-class-with-a-resource-type-since-130| @Model(resourceType="sling/any/resourceType") |
| applicablePaths	| dedicated annotation on Sling Model class, @ValidationPaths paths property  | @ValidationPaths(paths={"/content"\}) |
| properties\<propertyName>	| property name would be derived from either @ValueMapValue name attribute or the field's name.| @ValueMapValue(name="propertyName") |
| properties\<propertyName>\optional | value would be derived either from @ValueMapValue injectionStrategy property or from @Model class defaultInjectionStrategy property. | @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) or @Model(defaultInjectionStrategy = DefaultInjectionStrategy.REQUIRED) |
| properties\<propertyName>\propertyMultiple	| value would be derived from the field's type. If field is an Array or Collection - multiple = true | String[] properties or List<String> properties |
| properties\<propertyName>\nameRegex |	value would be derived from @Validate regex property. | @Validate(regex="*") |
| properties\<propertyName>\validators\<validatorName> |	validator name would be derived from @Validate validatorId property, where ID is a registered Validator component with same ID name. | @Validate(validatorId="org.apache.sling.validation.core.RegexValidator") |
| properties\<propertyName>\validators\<validatorName>\validatorArguments |	validator arguments would be derived from @Validate properties string array, where key and value must be split with equals sign "=" | @Validate(validatorId = "MinimumLengthValidator", properties= \{"minLength=10"\}) |
| properties\<propertyName>\validators\<validatorName>\severity |	severity would be derived from @Validate severity property, which by default is 0 | @Validate(severity=0)
| children\<resourceName> |	children would be derived from @ChildResource annotated fields, which are registered Sling Models | @ChildResource ChildModel model; |
| children\<resourceName>\nameRegex | child name would be derived either from @ChildResource name property or from fields name | @ChildResource(name="child") ChildModel model; |
| children\<resourceName>\optional |	optional would be derived either from @ChildResource injection strategy or from @Model class defaultInjectionStrategy property.  | @ChildResource(injectionStrategy = InjectionStrategy.OPTIONAL) or @Model(defaultInjectionStrategy = DefaultInjectionStrategy.REQUIRED) |
| children\<resourceName>\properties |	child properties would be derived from injected Sling Model @ValueMapValue fields |  |

> ValidationModelProvider evaluating additional annotations on a Sling Model bound to a specific resource type
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-6516
>                 URL: https://issues.apache.org/jira/browse/SLING-6516
>             Project: Sling
>          Issue Type: Improvement
>          Components: Validation
>            Reporter: Konrad Windszus
>
> Instead of providing a validation model through a dedicated sling resource with specific properties, it is often more handy to rely on annotations. A new ValidationModelProvider should support additional annotations on SlingModels defining a validation model for the underlying resource type of that SlingModel.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)