Uploaded image for project: 'PUBLIC - Liferay Alloy UI'
  1. PUBLIC - Liferay Alloy UI
  2. AUI-1654

Custom form validator rules should be easier to find and define

    Details

      Description

      Nowadays it's hard to know how to add custom rules to the form validator since you need to add a new property to the config object.

      Y.config.FormValidator.RULES.imageURL = function(val) {
          var regex = /(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/i;
          
          if (regex.test(val)) {
              return true;
          }
          else {
              return false;
          }
      }
          
      Y.config.FormValidator.STRINGS.imageURL = 'Please enter a valid URL that points to an image (jpg, jpeg, png, or gif).';
      
      var form = new Y.FormValidator({
          boundingBox: '#form',
          rules: {
              'image-url': {
                  imageURL: true,
                  required: true
              }
          }
      });
      

      Developers who are not used to check AlloyUI's source code might not find how to achieve that.

      Would be nice if we could provide a better API for custom rules.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              eduardo.lundgren Eduardo Lundgren (Inactive)
              Reporter:
              zeno.rocha Zeno Rocha
              Participants of an Issue:
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 11 weeks, 2 days ago

                  Packages

                  Version Package
                  2.0.x
                  master
                  master-deprecated
                  3.0.x
                  2.0.0.64-deprecated
                  3.1.x