Uploaded image for project: 'Blossom'
  1. Blossom
  2. BLOSSOM-288

Validator is always executed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 3.5.0
    • 3.4.7
    • None
    • None

      Steps to reproduce

      1.  Create a component in Blossom (e.g, a textField)
      2.  Set a validator:
        cfg.fields.text("cityId")
          .validator(cfg.validators.digitsOnly()
          .errorMessage("Only numbers"))
          .label("City Id")
          .description("Insert the Id of the city")
      1.  Check that when setting the validator, old info.magnolia.ui.form.validator.definition.RegexpValidatorDefinition class is instantiated instead of info.magnolia.ui.field.RegexpValidatorDefinition
      2.  Don't fulfill any value at the previous field (cityId)
      3.  Try to save the dialog
      4.  Check the validator is triggered tho no value has been typed

      Expected results

      Validator is executed only if the field has data

      Actual results

      Validator is always executed

      Workaround

      Switch to new M6UI info.magnolia.ui.field.RegexpValidatorDefinition class

      Development notes

      This is not directly a Blossom issue, same behavior happens for any field regardless the definition process. E.g, go to our demo and edit the TextAndImage component. At the headline section include the following validator (old class):

      - name: headline
        class: info.magnolia.ui.form.field.definition.TextFieldDefinition
        i18n: true
        validators:
          - name: digitsOnly
            class: info.magnolia.ui.form.validator.definition.RegexpValidatorDefinition
            pattern: ^\d{5}(-\d{4})?$
            errorMessage: Please, enter a number

      Now go to Pages app, create a new page and on the main area, create a TextAndImage component. Try to save it without inputing any value and check the validator is executed.

      Perform the same test at the mtk2 with the new regexValidator class:

      validators:
        numberValidator:
          $type: regexpValidator
          pattern: ^[+]*[0-9\s]*
          errorMessage: Please enter a number

      Check that if you try to save the dialog when no data has been included at the headline field, the dialog gets saved properly.

        Acceptance criteria

              jbenito Javier Benito
              ccantalapiedra Carlos Cantalapiedra
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - Not Specified
                    Not Specified
                    Logged:
                    Time Spent - 3h
                    3h