Grails
  1. Grails
  2. GRAILS-3802

Add custom constraints based on convetion

    Details

    • Type: New Feature New Feature
    • Status: Reopened
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.1-beta2
    • Fix Version/s: None
    • Component/s: Persistence
    • Labels:
      None

      Description

      Currently custom constraints can be added using the Config.groovy class as described inhttp://www.zorched.net/2008/01/26/custom-validators-in-grails-in-a-single-app/

      E.g.: org.codehaus.groovy.grails.validation.ConstrainedProperty.registerNewConstraint(
      PostalCodeConstraint.POSTAL_CODE_CONSTRAINT, PostalCodeConstraint.class)

      I think it would be great if constraints can be added by convention.
      E.g. add the PostcodeConstraint to some folder/package (utils?) and that Grails picks it up automatically and registers it. Just like it does it with the Codecs.

        Activity

        Hide
        Peter Ledbrook added a comment -

        No more new features for 1.1 at this juncture. Also, we don't consider this as critical.

        Show
        Peter Ledbrook added a comment - No more new features for 1.1 at this juncture. Also, we don't consider this as critical.
        Hide
        Marcel Overdijk added a comment -

        There is an implementation available using new plugin:
        http://tinyurl.com/yz9ypsq
        http://tinyurl.com/yjrpnb2

        Show
        Marcel Overdijk added a comment - There is an implementation available using new plugin: http://tinyurl.com/yz9ypsq http://tinyurl.com/yjrpnb2
        Hide
        Graeme Rocher added a comment -

        There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3

        for 1.2 final only issues considered blocking will now be fixed

        Show
        Graeme Rocher added a comment - There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3 for 1.2 final only issues considered blocking will now be fixed
        Hide
        Burt Beckwith added a comment -

        Closing since the referenced plugin implements the request.

        Show
        Burt Beckwith added a comment - Closing since the referenced plugin implements the request.
        Hide
        Marcel Overdijk added a comment -

        Hi Burt,

        I think it would be good considering adding the plugin's functionality to Grails core.
        Seems to me very basic stuff everyone Grails user could/should benefit off. See also number of voters.
        Another reason to merge this with core is that you never know if the plugin will be working/supported in future Grails version.

        Show
        Marcel Overdijk added a comment - Hi Burt, I think it would be good considering adding the plugin's functionality to Grails core. Seems to me very basic stuff everyone Grails user could/should benefit off. See also number of voters. Another reason to merge this with core is that you never know if the plugin will be working/supported in future Grails version.
        Hide
        Markus Mueller added a comment -

        + 1 for Marcels suggestion

        Show
        Markus Mueller added a comment - + 1 for Marcels suggestion
        Hide
        Marcel Overdijk added a comment -

        I would propose putting constraints in grails-app/contraints
        By default Grails doesn't even need to create this folder.
        Perhaps a create-custom-contraints script would be helpful, but not required at all.

        Show
        Marcel Overdijk added a comment - I would propose putting constraints in grails-app/contraints By default Grails doesn't even need to create this folder. Perhaps a create-custom-contraints script would be helpful, but not required at all.

          People

          • Assignee:
            Burt Beckwith
            Reporter:
            Marcel Overdijk
          • Votes:
            13 Vote for this issue
            Watchers:
            14 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development