Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-4161

Support Sling Validation through a new field of the Model annotation

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      The current way of integrating Sling Validation (SLING-2803) with Sling Models is to inject the validation service and then call it within a PostConstruct method (http://www.slideshare.net/raducotescu/apache-sling-generic-validation-framework/16).
      This has the drawback that

      1. the ValidationService needs to be injected
      2. a PostConstruct needs to be implemented
      3. the other injections need to be marked as optional (otherwise the validation is never triggered in case of e.g. missing required valuemap values)

      Instead it would be good to support this use case with just an additional field on the annotation Model which is named validate. By default this should be false (to be backwards compatible), but if it is true the Sling Validation should be called before any values are injected into the model. If validation fails the ModelAdapterFactory should never instanciate the model and rather return null (or throw a meaningful exception for SLING-3709).

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            kwin Konrad Windszus
            kwin Konrad Windszus
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment