Netlify-cms: Pattern validation ignored on list widget

Created on 14 Jun 2019  路  3Comments  路  Source: netlify/netlify-cms

Describe the bug
The regex pattern validation does work on normal string widgets but it does not work on a list widget with strings.

To Reproduce
Use the following widget settings:

{
  label: "Tags",
  name: "tags",
  widget: "list",
  pattern:
    [
      "^[^\\s#]+$",
      "No spaces and # allowed in tags. Please separate multiple tags with comma.",
    ]
}

Then in the CMS it is still possible to create tags with spaces and hashtags that means the validation pattern is not applied at all.

Expected behavior
For list widgets that use the default comma-separated text input the regex pattern should be applied.

Applicable Versions:
netlify-cms-app 2.9.1
netlify-cms-core 2.11.0
netlify-cms 2.9.1

extensionwidgets validation bug

Most helpful comment

@erquhart done #2482

All 3 comments

The pattern validation almost works, but not completely. Now I get this weird effect:

If I edit the tags (as in the example above), everything gets validated as expected and if valid I can save the post.

But if I reopen the post and change something else and try to save, the pattern on the tags suddenly turns red. Then if I just make a random edit in the tags field, the validation works again.

Should I reopen a new issue for that?

@marcojakob could have sworn I commented on this - yes, please open a new issue if you haven't already.

@erquhart done #2482

Was this page helpful?
0 / 5 - 0 ratings