mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 11:54:10 +00:00 
			
		
		
		
	CTB: Improve UI validation for enum values
Co-authored-by: omacovei <omacovei@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									92558c8238
								
							
						
					
					
						commit
						b582e770b7
					
				@ -4,7 +4,6 @@ import { translatedErrors as errorsTrads } from '@strapi/helper-plugin';
 | 
			
		||||
import getTrad from '../../../utils/getTrad';
 | 
			
		||||
import getRelationType from '../../../utils/getRelationType';
 | 
			
		||||
import toRegressedEnumValue from '../../../utils/toRegressedEnumValue';
 | 
			
		||||
import startsWithANumber from '../../../utils/startsWithANumber';
 | 
			
		||||
import {
 | 
			
		||||
  alreadyUsedAttributeNames,
 | 
			
		||||
  createTextShape,
 | 
			
		||||
@ -169,9 +168,9 @@ const types = {
 | 
			
		||||
          test: values => !values.some(val => val === ''),
 | 
			
		||||
        })
 | 
			
		||||
        .test({
 | 
			
		||||
          name: 'doesNotStartWithANumber',
 | 
			
		||||
          message: getTrad('error.validation.enum-number'),
 | 
			
		||||
          test: values => !values.some(startsWithANumber),
 | 
			
		||||
          name: 'doesMatchRegex',
 | 
			
		||||
          message: getTrad('error.validation.enum-regex'),
 | 
			
		||||
          test: values => values.map(toRegressedEnumValue).every(value => ENUM_REGEX.test(value)),
 | 
			
		||||
        }),
 | 
			
		||||
      enumName: yup.string().nullable(),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@ -60,7 +60,7 @@
 | 
			
		||||
  "error.contentTypeName.reserved-name": "This name cannot be used in your project as it might break other functionalities",
 | 
			
		||||
  "error.validation.enum-duplicate": "Duplicate values are not allowed",
 | 
			
		||||
  "error.validation.enum-empty-string": "Empty strings are not allowed",
 | 
			
		||||
  "error.validation.enum-number": "Values cannot start with a number",
 | 
			
		||||
  "error.validation.enum-regex": "At least one value contains invalid characters. Non alphanumerical characters should not be followed by numbers at the beginning of a value.",
 | 
			
		||||
  "error.validation.minSupMax": "Can't be superior",
 | 
			
		||||
  "error.validation.positive": "Must be a positive number",
 | 
			
		||||
  "error.validation.regex": "Regex pattern is invalid",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user