Skip to content

Commit

Permalink
feat: field invalidate() methods arguments updated, introduced deep
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Jan 14, 2024
1 parent bb99862 commit 411b8d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 6.8.0 (master)
- Field `invalidate()` methods arguments updated, introduced `deep`.

# 6.7.5 (master)
- better handling of `deep` argument for `showErrors()` & `invalidate()` methods.
- removed `mixed` mode warning
Expand Down
7 changes: 4 additions & 3 deletions src/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,20 +719,21 @@ export default class Field extends Base implements FieldInterface {
}
}

invalidate(message: string, async: boolean = false): void {
invalidate(message: string, deep: boolean = true, async: boolean = false): void {
if (async === true) {
this.errorAsync = message;
this.showErrors(true, deep);
return;
}

if (Array.isArray(message)) {
this.validationErrorStack = message;
this.showErrors(true);
this.showErrors(true, deep);
return;
}

this.validationErrorStack.unshift(message);
this.showErrors(true);
this.showErrors(true, deep);
}

setValidationAsyncData(valid: boolean = false, message: string = ""): void {
Expand Down
2 changes: 1 addition & 1 deletion src/models/FieldInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface FieldInterface extends BaseInterface {
getComputedProp(key: any): any;
checkValidationPlugins(): void;
initNestedFields(field: any, update: boolean): void;
invalidate(message?: string, async?: boolean): void;
invalidate(message?: string, deep?: boolean, async?: boolean): void;
setValidationAsyncData(valid: boolean, message: string): void;
resetValidation(deep: boolean): void;
clear(deep?: boolean): void;
Expand Down

0 comments on commit 411b8d7

Please sign in to comment.