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 {
|
class ValidateField {
|
||||||
#field
|
#field
|
||||||
#extraChecks = []
|
#extraChecks = {}
|
||||||
|
|
||||||
constructor(field) {
|
constructor(field) {
|
||||||
this.#field = field
|
this.#field = field
|
||||||
@ -26,10 +26,7 @@ class ValidateField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addExtraCheck = (validateFunc) => {
|
addExtraCheck = (validateFunc) => {
|
||||||
if (!this.#extraChecks.includes(validateFunc)) {
|
this.#extraChecks[validateFunc.name] = validateFunc
|
||||||
this.#extraChecks.push(validateFunc)
|
|
||||||
}
|
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,10 +40,8 @@ class ValidateField {
|
|||||||
|
|
||||||
// run extra checks
|
// run extra checks
|
||||||
let valid = true
|
let valid = true
|
||||||
console.log(this.#extraChecks)
|
for (const validateFuncName in this.#extraChecks) {
|
||||||
|
valid = this.#extraChecks[validateFuncName](this.#field)
|
||||||
for (const validateFunc of this.#extraChecks) {
|
|
||||||
valid = validateFunc(this.#field)
|
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
break
|
break
|
||||||
|
@ -6,7 +6,7 @@ const NAME = 'ui.validate.form'
|
|||||||
class ValidateForm {
|
class ValidateForm {
|
||||||
#steppedUI
|
#steppedUI
|
||||||
#form
|
#form
|
||||||
#extraChecks = []
|
#extraChecks = {}
|
||||||
|
|
||||||
constructor(form) {
|
constructor(form) {
|
||||||
this.#form = form
|
this.#form = form
|
||||||
@ -61,10 +61,7 @@ class ValidateForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addExtraCheck = (validateFunc) => {
|
addExtraCheck = (validateFunc) => {
|
||||||
if (!this.#extraChecks.includes(validateFunc)) {
|
this.#extraChecks[validateFunc.name] = validateFunc
|
||||||
this.#extraChecks.push(validateFunc)
|
|
||||||
}
|
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +84,8 @@ class ValidateForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// run extra checks
|
// run extra checks
|
||||||
for (const validateFunc of this.#extraChecks) {
|
for (const validateFuncName in this.#extraChecks) {
|
||||||
valid = validateFunc(this.#form)
|
valid = this.#extraChecks[validateFuncName](this.#form)
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user