Check kebab case only if value is defined

This commit is contained in:
Alexandre Bodin 2023-06-27 15:16:34 +02:00
parent e69479f68d
commit c574622447

View File

@ -33,7 +33,7 @@ yup.addMethod(
'isCamelCase', 'isCamelCase',
function isCamelCase(message = '${path} is not in camel case (anExampleOfCamelCase)') { function isCamelCase(message = '${path} is not in camel case (anExampleOfCamelCase)') {
return this.test('is in camelCase', message, (value) => return this.test('is in camelCase', message, (value) =>
value ? utils.isCamelCase(value) : false value ? utils.isCamelCase(value) : true
); );
} }
); );
@ -43,7 +43,7 @@ yup.addMethod(
'isKebabCase', 'isKebabCase',
function isKebabCase(message = '${path} is not in kebab case (an-example-of-kebab-case)') { function isKebabCase(message = '${path} is not in kebab case (an-example-of-kebab-case)') {
return this.test('is in kebab-case', message, (value) => return this.test('is in kebab-case', message, (value) =>
value ? utils.isKebabCase(value) : false value ? utils.isKebabCase(value) : true
); );
} }
); );