Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding validations when setFields is triggered #661

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
9 changes: 6 additions & 3 deletions src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ export class FormStore {
data: fieldData,
});
});

//validation of the fields to be rerun when someone sets the value using setFields/setFieldValue
this.validateFields(namePathList)
this.notifyWatch(namePathList);
};

Expand Down Expand Up @@ -764,16 +765,18 @@ export class FormStore {
this.warningUnhooked();

const prevStore = this.store;

const namesLists = Object.keys(store);
if (store) {
const nextStore = merge(this.store, store);
this.updateStore(nextStore);
}

}
this.notifyObservers(prevStore, null, {
type: 'valueUpdate',
source: 'external',
});
//validation of the fields to be rerun when someone sets the value using setFieldsValue
this.validateFields(namesLists)
this.notifyWatch();
};

Expand Down