Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,43 +1012,47 @@ class JustValidate {
}

handleFieldChange = (target: HTMLInputElement): void => {
let foundKey;
const foundKeys: string[] = [];

for (const key in this.fields) {
const field = this.fields[key];

if (field.elem === target) {
foundKey = key;
break;
foundKeys.push(key);
}
}

if (!foundKey) {
if (foundKeys.length === 0) {
return;
}

this.fields[foundKey].touched = true;
this.validateField(foundKey, true);
// Process each found key
foundKeys.forEach((key) => {
this.fields[key].touched = true;
this.validateField(key, true);
});
};

handleGroupChange = (target: HTMLInputElement): void => {
let foundKey;
const foundKeys: string[] = [];

for (const key in this.groupFields) {
const group = this.groupFields[key];

if (group.elems.find((elem) => elem === target)) {
foundKey = key;
break;
foundKeys.push(key);
}
}

if (!foundKey) {
if (foundKeys.length === 0) {
return;
}

this.groupFields[foundKey].touched = true;
this.validateGroup(foundKey, true);
// Process each found key
foundKeys.forEach((key) => {
this.groupFields[key].touched = true;
this.validateGroup(key, true);
});
};

handlerChange = (ev: Event): void => {
Expand Down