Skip to content

Pattern Validation via UI Component Fails to Interpret String as RegEx Pattern #9919

Closed
@bap14

Description

@bap14

When using a UI Component based form and adding a custom regular expression pattern validation to an input field, the supplied pattern is not properly converted from a string to a javascript RegEx object.

Preconditions

  1. Magento EE 2.1.7, Magento CE 2.1.7
  2. PHP 7.0.17
  3. MySQL 5.7.18

Steps to reproduce

  1. Create a custom UI Component form

  2. Add a validation item to an input field

  3. Specify a pattern validation rule with a custom regular expression pattern. E.g.

     <item name="validation" xsi:type="array">
         <item name="required-entry" xsi:type="boolean">true</item>
         <item name="no-whitespace" xsi:type="boolean">true</item>
         <item name="pattern" xsi:type="string">^[a-zA-Z][a-zA-Z0-9_.-]{3,}$</item>
     </item>
    

Expected result

  1. The pattern value should be interpreted as a RegEx object OR sent through new RegEx within the javascript.

Actual result

  1. A javascript error is thrown that param.test is not a function.
    screen shot 2017-06-12 at 11 17 55 am
    screen shot 2017-06-12 at 11 16 16 am

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrontendFixed in 2.1.xThe issue has been fixed in 2.1 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions