final-form / final-form/react-final-form

Changing Field Level Validators does not work on the Field component with the validation

Open
#811 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

### Are you submitting a **bug report** or a **feature request**?
**bug report**

### What is the current behavior?
Changing field level validator as shown in the demo linked to by the documentation of the validate property does not work as epected when the Field-component with the validator uses a render function to display errors.

Replace line 39; component="input"
With: render={p => <>{p.meta.error}}

When toggling the checkbox that defines if the text field is required, the validation error is displayed correctly in the Error component and in the JSON at the buttom of the demo, but not in the render function of the text fields.

### What is the expected behavior?
When the checkbox is unchecked (and the text field is empty) I would expecte p.meta.error to be undefined in the render function of the text field.

### Sandbox Link
Original demo: https://codesandbox.io/s/changing-field-level-validators-zc8ei?fontsize=14
Example showing the bug: https://codesandbox.io/s/changing-field-level-validators-bv4ji?file=/src/index.js

### What's your environment?
Codesandbox.io using Google Chrome.
react-final-fom: 6.3.0

### Other information
It is only the Field component with the validator that does not display the expected error. Inserting other Field-components with the name="first" gets the correct error message. This is what the Error-component does.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.