decaporg / decaporg/decap-cms

Field pattern not working correctly on creating/editing posts

Open
#6,500 0 comments 1 reaction 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**
We have some fields with pattern usage like `/^.{0,130}$/gmi`
If I create a new post, this works fine.
But when I edit a post, I receive an error message, that the fields content doesn't match my regex pattern.
Sometimes it works and sometimes it won't, seems to be very flaky ....

Works correctly
![image](https://user-images.githubusercontent.com/49027330/175962871-52925462-051b-4c75-ad8d-b56538b766ba.png)

Should also work correctly
![image](https://user-images.githubusercontent.com/49027330/175963141-c0e67f3f-4837-4bd6-9813-6902eb1201de.png)

**To Reproduce**
1. Create a field configuration with a field like
`{
label: 'Teaser',
name: 'teaser',
widget: 'text',
pattern: [/^.{0,130}$/gmi, 'Max amount of 130 characters'],
}`

2. Create a new post with this field filled correctly (tested this using regexr.com)
3. Save the new post, all should works fine
4. Edit the post and add or remove a line
5. Try to save it, you'll receive an error

**Expected behavior**
Pattern work correctly on editing

**Screenshots**
See above

**Applicable Versions:**
- "netlify-cms-app": "^2.15.72",

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.