-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
Version
3.2.5
Environment
Described in the package.json
Reproduction link
https://github.com/Oleksii14/ant-design-form-validation-issue
Steps to reproduce
- npm i
- npm run dev
- open the app in the browser
- The form is valid on init, but the validateInfos object is empty so I cannot calculate whether the form is valid initially
Can be fixed by calling validate method from useForm. It will actualize the validateInfos
What is expected?
The validateInfos object should have the actual data (including validateStatus) after component init at once
What is actually happening?
While trying to calculate whether the form is valid or not initially, I noticed that validateInfos object does not contain needed info in the beginning. It is being changed only when starting filling the form
Using the code in the reproduction repo, the current behavior is:
// validateInfos on init
{
name: {autoLink: false, required: false},
lastName: {autoLink: false, required: false}
}
Should be:
// validateInfos on init
{
name: {autoLink: false, required: false, validateStatus: "success"},
lastName: {autoLink: false, required: false, validateStatus: "success"}
}
The main question on this issue:
Is there a way apart from the approach mentioned in this repo to track the form's validation status?
Use case:
const isFormValid = ...
// template
<button :disabled="!isFormValid">submit</button>
