Skip to content

validateInfos object is not actual during component init #5666

@Oleksii14

Description

@Oleksii14
  • 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

  1. npm i
  2. npm run dev
  3. open the app in the browser
  4. 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"}
}

image

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>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions