mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 15:32:42 +00:00
Merge pull request #4767 from strapi/ctb/fix-category-regex
Update ctb's category regex
This commit is contained in:
commit
6ed4298992
@ -1,4 +1,5 @@
|
||||
const NAME_REGEX = new RegExp('^[A-Za-z][_0-9A-Za-z]*$');
|
||||
const CATEGORY_NAME_REGEX = new RegExp('^[A-Za-z][-_0-9A-Za-z]*$');
|
||||
const ENUM_REGEX = new RegExp('^[_A-Za-z][_0-9A-Za-z]*$');
|
||||
const NAME_REGEX = new RegExp('^[A-Za-z][_0-9A-Za-z]*$');
|
||||
|
||||
export { ENUM_REGEX, NAME_REGEX };
|
||||
export { CATEGORY_NAME_REGEX, ENUM_REGEX, NAME_REGEX };
|
||||
|
||||
@ -8,7 +8,11 @@ import getTrad from '../../../utils/getTrad';
|
||||
import { createComponentUid, createUid, nameToSlug } from './createUid';
|
||||
import componentForm from './componentForm';
|
||||
import fields from './staticFields';
|
||||
import { NAME_REGEX, ENUM_REGEX } from './attributesRegexes';
|
||||
import {
|
||||
NAME_REGEX,
|
||||
ENUM_REGEX,
|
||||
CATEGORY_NAME_REGEX,
|
||||
} from './attributesRegexes';
|
||||
import RESERVED_NAMES from './reservedNames';
|
||||
|
||||
yup.addMethod(yup.mixed, 'defined', function() {
|
||||
@ -829,7 +833,7 @@ const forms = {
|
||||
.required(errorsTrads.required),
|
||||
category: yup
|
||||
.string()
|
||||
.matches(NAME_REGEX, errorsTrads.regex)
|
||||
.matches(CATEGORY_NAME_REGEX, errorsTrads.regex)
|
||||
.required(errorsTrads.required),
|
||||
icon: yup.string().required(errorsTrads.required),
|
||||
collectionName: yup.string().nullable(),
|
||||
@ -892,6 +896,7 @@ const forms = {
|
||||
return yup.object().shape({
|
||||
name: yup
|
||||
.string()
|
||||
.matches(CATEGORY_NAME_REGEX, errorsTrads.regex)
|
||||
.unique(errorsTrads.unique, allowedCategories, toLower)
|
||||
.required(errorsTrads.required),
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user