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

Ability to check if a form is valid without having to display the errors/feedback on the UI (leveraging formInstance.validateFields) #25993

Open
1 task done
chandu opened this issue Aug 3, 2020 · 3 comments
Labels

Comments

@chandu
Copy link

chandu commented Aug 3, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

The FormInstance has a method validateFields: (nameList?: NamePath[]) => Promise which can be used to check if a field/all fields of the form are valid or not. This also updates the UI to display error messages/feedback on the form.
However there could be use cases where we just need to know if the form is valid or not without displaying any feedback/errors. (e.g: displaying form for the first time with pre-populated data from external source etc.)

As an example @ the CAB https://codesandbox.io/s/bitter-frost-btmsy
When I click on the Validate button, I would like to know if the form is valid or not without showing the errors/feedback on the UI.
But right now the this is not possible.

This can be useful to let's say enabling/disabling Submit button etc.

What does the proposed API look like?

May be we can add an option/flag to the validateFields to allow checking the form is valid or not without any UI errors/feedback.

e.g: validateFields: (nameList?: NamePath[], options?: { showErrors?: boolean }) => Promise

@wangxingkang
Copy link
Member

有计划支持吗

@rpelorosso
Copy link

Is there a solution to this?

@slampazona
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants