mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
FIX: form/field validation extra checks repeated funcs
This commit is contained in:
parent
2fc7882cf7
commit
52cade10c8
@ -3,7 +3,7 @@ const NAME = 'ui.validate.field'
|
||||
|
||||
class ValidateField {
|
||||
#field
|
||||
#extraChecks = []
|
||||
#extraChecks = {}
|
||||
|
||||
constructor(field) {
|
||||
this.#field = field
|
||||
@ -26,10 +26,7 @@ class ValidateField {
|
||||
}
|
||||
|
||||
addExtraCheck = (validateFunc) => {
|
||||
if (!this.#extraChecks.includes(validateFunc)) {
|
||||
this.#extraChecks.push(validateFunc)
|
||||
}
|
||||
|
||||
this.#extraChecks[validateFunc.name] = validateFunc
|
||||
return this
|
||||
}
|
||||
|
||||
@ -43,10 +40,8 @@ class ValidateField {
|
||||
|
||||
// run extra checks
|
||||
let valid = true
|
||||
console.log(this.#extraChecks)
|
||||
|
||||
for (const validateFunc of this.#extraChecks) {
|
||||
valid = validateFunc(this.#field)
|
||||
for (const validateFuncName in this.#extraChecks) {
|
||||
valid = this.#extraChecks[validateFuncName](this.#field)
|
||||
|
||||
if (!valid) {
|
||||
break
|
||||
|
@ -6,7 +6,7 @@ const NAME = 'ui.validate.form'
|
||||
class ValidateForm {
|
||||
#steppedUI
|
||||
#form
|
||||
#extraChecks = []
|
||||
#extraChecks = {}
|
||||
|
||||
constructor(form) {
|
||||
this.#form = form
|
||||
@ -61,10 +61,7 @@ class ValidateForm {
|
||||
}
|
||||
|
||||
addExtraCheck = (validateFunc) => {
|
||||
if (!this.#extraChecks.includes(validateFunc)) {
|
||||
this.#extraChecks.push(validateFunc)
|
||||
}
|
||||
|
||||
this.#extraChecks[validateFunc.name] = validateFunc
|
||||
return this
|
||||
}
|
||||
|
||||
@ -87,8 +84,8 @@ class ValidateForm {
|
||||
}
|
||||
|
||||
// run extra checks
|
||||
for (const validateFunc of this.#extraChecks) {
|
||||
valid = validateFunc(this.#form)
|
||||
for (const validateFuncName in this.#extraChecks) {
|
||||
valid = this.#extraChecks[validateFuncName](this.#form)
|
||||
|
||||
if (!valid) {
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user