Do not rquire min length for all password fields

This commit is contained in:
Adria Navarro 2023-06-19 14:53:02 +01:00
parent 702f59a90e
commit 76ac28f550
2 changed files with 4 additions and 7 deletions

View File

@ -16,7 +16,7 @@
let password = null
const validation = createValidationStore()
validation.addValidatorType("password", "password", true)
validation.addValidatorType("password", "password", true, { minLength: 8 })
$: validation.observe("password", password)
const Step = { CONFIG: "config", SET_PASSWORD: "set_password" }

View File

@ -21,7 +21,7 @@ export const createValidationStore = () => {
validator[propertyName] = propertyValidator
}
const addValidatorType = (propertyName, type, required) => {
const addValidatorType = (propertyName, type, required, options) => {
if (!type || !propertyName) {
return
}
@ -45,11 +45,8 @@ 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
if (options?.minLength) {
propertyValidator = propertyValidator.min(options.minLength)
}
validator[propertyName] = propertyValidator