mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
IMPR: Add validate form/field functionality
This commit is contained in:
parent
8f55fa6ef4
commit
2fc7882cf7
@ -25,8 +25,12 @@ class ValidateField {
|
||||
this.#field.dispatchEvent(new Event(Events.FORM_INIT_VALIDATE_FIELD))
|
||||
}
|
||||
|
||||
addExtraCheck = (func) => {
|
||||
this.#extraChecks.push(func)
|
||||
addExtraCheck = (validateFunc) => {
|
||||
if (!this.#extraChecks.includes(validateFunc)) {
|
||||
this.#extraChecks.push(validateFunc)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
validate = () => {
|
||||
@ -39,8 +43,10 @@ class ValidateField {
|
||||
|
||||
// run extra checks
|
||||
let valid = true
|
||||
for (const func in this.#extraChecks) {
|
||||
valid = func(this.#field)
|
||||
console.log(this.#extraChecks)
|
||||
|
||||
for (const validateFunc of this.#extraChecks) {
|
||||
valid = validateFunc(this.#field)
|
||||
|
||||
if (!valid) {
|
||||
break
|
||||
|
@ -60,8 +60,12 @@ class ValidateForm {
|
||||
}
|
||||
}
|
||||
|
||||
addExtraCheck = (func) => {
|
||||
this.#extraChecks.push(func)
|
||||
addExtraCheck = (validateFunc) => {
|
||||
if (!this.#extraChecks.includes(validateFunc)) {
|
||||
this.#extraChecks.push(validateFunc)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
validate = async () => {
|
||||
@ -83,8 +87,8 @@ class ValidateForm {
|
||||
}
|
||||
|
||||
// run extra checks
|
||||
for (const func in this.#extraChecks) {
|
||||
valid = func(this.#form)
|
||||
for (const validateFunc of this.#extraChecks) {
|
||||
valid = validateFunc(this.#form)
|
||||
|
||||
if (!valid) {
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user