[MGNLUI-6454] nodeNameValidator: introduce ability to redefine regular expression Created: 11/Dec/20  Updated: 19/Jul/21  Resolved: 08/Jul/21

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2.5
Fix Version/s: 6.2.11

Type: Improvement Priority: Neutral
Reporter: Boris Faniuk Assignee: Andrei Ichimescu
Resolution: Fixed Votes: 0
Labels: maintenance
Remaining Estimate: Not Specified
Time Spent: 14m
Original Estimate: Not Specified

Issue Links:
documentation
to be documented by MGNLUI-6794 DOC: 'pattern' property also used in ... Closed
relation
is related to MGNLUI-6455 nodeNameValidator doesn't work correc... Closed
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[X]  Architecture Decision Record (ADR)
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Sprint: Maintenance 64, Maintenance 65
Story Points: 2

 Description   

Currently pattern for node name validation is hard coded and just checks for non-empty value. This validation never really works as empty page name will result in "field is required" validation to be fired.
What would make more sense is to catch unwanted symbols here (as anyway they will replaced by dash in nodeNameHelper.getValidatedName and that is unpredictable for editor).
In addition we would like to catch uppercase symbols as they cause issues in Linux environment.
I would propose to introduce pattern and errorMessage parameters that would allow us to define this pattern and avoid having 2 regexp validations for page name.



 Comments   
Comment by Boris Faniuk [ 15/Jan/21 ]

Created pull request with possible solution (see Development section)

Comment by Richard Gange [ 15/Jan/21 ]

Thanks bfaniuk. Can you please adjust the permissions on the repo? We are blocked since it's forked to your personal repo.

Comment by Boris Faniuk [ 15/Jan/21 ]

Hello, Richard! I assigned "Write" permission to "magnolia-dev" group. Is this enough?

Comment by Richard Gange [ 15/Jan/21 ]

Perfect, thank you

Comment by Andrei Ichimescu [ 08/Jul/21 ]

Fix by enhancing the nodeNameValidator with regular expression patterns

config example:
validators:

  • $type: nodeNameValidator
    mode: ADD
    pattern: _.+
    errorMessage: The name must start with an underscore

The pattern and errorMessage properties are optional the default value are: pattern: .+ errorMessage: Node name can't be empty

Generated at Mon Feb 12 09:36:37 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.