From 5b77e01e99ac56433cd59cdcc4fbe12e6842d5ed Mon Sep 17 00:00:00 2001 From: Nikhil Date: Tue, 12 Mar 2024 16:27:29 +0530 Subject: [PATCH 1/3] Adding validations when setFields is triggered --- docs/examples/validate.tsx | 19 +++++++++++++++++++ src/useForm.ts | 7 ++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/examples/validate.tsx b/docs/examples/validate.tsx index 3a3b29f9a..bfa740c76 100644 --- a/docs/examples/validate.tsx +++ b/docs/examples/validate.tsx @@ -38,6 +38,7 @@ export default () => { return (

Validate Form

+
{(values, form) => { const usernameError = form.getFieldError('username'); @@ -50,6 +51,24 @@ export default () => { return ( + Date: Wed, 13 Mar 2024 09:57:33 +0530 Subject: [PATCH 2/3] changes new --- docs/examples/validate.tsx | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/docs/examples/validate.tsx b/docs/examples/validate.tsx index bfa740c76..3a3b29f9a 100644 --- a/docs/examples/validate.tsx +++ b/docs/examples/validate.tsx @@ -38,7 +38,6 @@ export default () => { return (

Validate Form

- {(values, form) => { const usernameError = form.getFieldError('username'); @@ -51,24 +50,6 @@ export default () => { return ( - Date: Wed, 13 Mar 2024 10:00:04 +0530 Subject: [PATCH 3/3] changes new --- src/useForm.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/useForm.ts b/src/useForm.ts index 2d2c27a90..4a083230b 100644 --- a/src/useForm.ts +++ b/src/useForm.ts @@ -586,6 +586,7 @@ 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); }; @@ -774,6 +775,7 @@ export class FormStore { type: 'valueUpdate', source: 'external', }); + //validation of the fields to be rerun when someone sets the value using setFieldsValue this.validateFields(namesLists) this.notifyWatch(); };