Fix validation order

This commit is contained in:
Adria Navarro 2023-06-13 13:07:41 +01:00
parent d041ad621f
commit 5f3335c566
1 changed files with 8 additions and 1 deletions

View File

@ -35,7 +35,7 @@ export const createValidationStore = () => {
propertyValidator = string().email().nullable()
break
case "password":
propertyValidator = string().min(8)
propertyValidator = string().nullable()
break
default:
propertyValidator = string().nullable()
@ -45,6 +45,13 @@ export const createValidationStore = () => {
propertyValidator = propertyValidator.required()
}
// We want to do this after the possible required validation, to prioritise the required error
switch (type) {
case "password":
propertyValidator = propertyValidator.min(8)
break
}
validator[propertyName] = propertyValidator
}