Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
fix(Formbot): Validate fields when setting state directly (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikshestopal authored Jul 26, 2019
1 parent 88f197c commit 944fdd1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Form/Formbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ export default class Formbot extends React.Component {
}

setValues(values = {}) {
this.setState({
values: {
...this.state.values,
...values,
this.setState(
{
values: {
...this.state.values,
...values,
},
},
});
this.validateAllFields
);
}

updateField(field, updates = {}) {
Expand Down Expand Up @@ -173,7 +176,9 @@ export default class Formbot extends React.Component {

validateAllFields() {
return Promise.all(
this.validatableFields.map(field => this.updateField(field, {}).then(() => this.validateField(field)))
this.validatableFields.map(field =>
this.updateField(field, { validated: false }).then(() => this.validateField(field))
)
);
}

Expand Down

0 comments on commit 944fdd1

Please sign in to comment.