decap-cms: Validation error throws no matter what when checking range length
Tried to add validation for a text widget to make sure that there are no more then 250 characts and no less then five. I tried using pattern: [ ‘/^[0-9A-Za-z]{5,250}$/’, ‘This field must be no more than 250 characters and no less then 5 characters’, ]
but it didn’t work correctly.
Here is what i have:
Screenshots
Describe the bug Validation throwing error with regex and pattern
Expected behavior Allows me to publish if the character length in the text widget equal to or are within the range of 5 and 250.
Applicable Versions:
- Netlify CMS version: 3.0.14
- Git provider: GitHub
- OS: Windows 10
- Browser version chrome version 73.0.3683.86]
- Node.JS version: v11.10.0
CMS configuration
backend:
name: git-gateway
branch: master
media_folder: static/img
public_folder: /img
collections:
- name: 'pages'
label: 'Pages'
create: true
files:
- file: 'src/pages/index.md'
label: 'Landing Page'
name: 'Index Page'
fields:
- {
label: 'Template Key',
name: 'templateKey',
widget: 'hidden',
default: 'index-page',
}
- { label: Title, name: title, widget: string }
- { label: Image, name: image, widget: image }
- { label: Heading, name: heading, widget: string }
- { label: Subheading, name: subheading, widget: string }
- {
label: About Section,
name: aboutSection,
widget: object,
fields:
[
{ label: Title, name: title, widget: string },
{ label: Paragraph One, name: paragraphOne, widget: text },
{ label: Paragraph Two, name: paragraphTwo, widget: text },
],
}
- {
label: Skills,
name: skills,
widget: object,
fields:
[
{
label: Skills,
name: skills,
widget: list,
fields:
[
{ label: Image, name: image, widget: image },
{ label: Title, name: title, widget: string },
],
},
],
}
- {
label: Featured Projects,
name: featuredProjects,
widget: object,
fields:
[
{ label: Heading, name: heading, widget: string },
{ label: Description, name: description, widget: text },
{
label: Projects,
name: projects,
widget: list,
fields:
[
{ label: Image, name: image, widget: image },
{ label: Text, name: text, widget: text },
{ label: Git Link, name: gitLink, widget: string },
{
label: Live Link (add \"\no link\" if no link),
name: liveLink,
widget: string,
},
],
},
],
}
- {
label: Main,
name: main,
widget: object,
fields:
[
{ label: Heading, name: heading, widget: string },
{ label: Description, name: description, widget: text },
],
}
- file: 'src/pages/portfolio/index.md'
label: 'Portfolio Page'
name: 'portfolio'
fields:
- {
label: 'Template Key',
name: 'templateKey',
widget: 'hidden',
default: 'porftolio-page',
}
- { label: Title, name: title, widget: string }
- { label: Image, name: image, widget: image }
- { label: Heading, name: heading, widget: string }
- { label: Description, name: description, widget: string }
- {
label: Intro,
name: intro,
widget: object,
fields:
[
{ label: Heading, name: heading, widget: string },
{ label: Description, name: description, widget: text },
{
label: Blurbs,
name: blurbs,
widget: list,
fields:
[
{ label: Image, name: image, widget: image },
{
label: Text,
name: text,
widget: text,
pattern:
[
'/^[a-zA-Z]{1,250}$/',
'This field must be no more than 250 characters and no less then 5 characters long',
],
},
],
},
],
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (7 by maintainers)
We should be releasing fixes soon.
@tomrutgers I did not catch that. Ill give it a shot
@talves Yeah, that’s why I’m asking 👍 @KyleAMathews can you downgrade to
2.6.1and check if it works?@tomrutgers not sure it is related, but 2.8.0 breaks netlify-cms on Gatsby using the plugin (fyi)
@barthc @KyleWiteck can confirm that
works as expected. Gives an error with a 4 letter word (and a 251 letter paragraph for that matter)