Skip to content

Commit

Permalink
Merge pull request #15 from josh-wer/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
joshuauyi committed Dec 5, 2020
2 parents c575c8b + 89da301 commit 502d097
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formidate",
"version": "0.2.2",
"version": "0.2.3",
"description": "Form validation library",
"author": "Joshua Uyi <joshuaouyi@gmail.com>",
"main": "lib/index.js",
Expand Down
9 changes: 3 additions & 6 deletions src/FormGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class FormGroup {
.async(this._values, toValidateRules, this.options)
.then(() => {
this.mappedErrors = {};
this.controls[name].setTouched(true).setErrors([]);
})
.catch((err: any) => {
if (err instanceof Error) {
Expand All @@ -191,13 +190,11 @@ class FormGroup {
}

this.mappedErrors = err || {};
const foundErrors: { [key: string]: string[] } = this.getGroupedErrors(this.mappedErrors);

// validate currently change field
this.controls[name].setTouched(true); // touch currently edited control
this.considered.forEach(controlName => this.controls[controlName].setErrors(foundErrors[controlName] || []));
})
.finally(() => {
this.controls[name].setTouched(true); // touch currently edited control
const foundErrors: { [key: string]: string[] } = this.getGroupedErrors(this.mappedErrors);
this.considered.forEach(controlName => this.controls[controlName].setErrors(foundErrors[controlName] || []));
this.controls[name].setLoading(controlIsLoading);
this.updateValidState();
});
Expand Down

0 comments on commit 502d097

Please sign in to comment.