react-jsonschema-form
react-jsonschema-form copied to clipboard
Cannot check for existing errors on field in CustomValidate
Prerequisites
- [X] I have searched the existing issues
- [X] I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [X] I have read the documentation
- [X] Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
core
Version
5.20.0
Current Behavior
I have a username field in my form that I want to invalidate if it is not unique. I check its uniqueness with an API call, which always runs in my CustomValidate function. However, it would be more efficient only to run it if there are no other prior errors on that field (I have a pattern in the JSON schema that disallows certain characters). I am trying to do a simple if based on the errors.username.__errors
variable, but no matter in which configuration I write the condition, I can only get it to always be true or never be true, regardless of the presence of other errors.
Expected Behavior
I expect a check such as if (!errors.username.__errors || errors.username.__errors.length === 0)
to be true if there are no errors associated to the username
field, and false if there is at least one.
Steps To Reproduce
No response
Environment
- OS: Windows 10
- Node: 20.15.0
- npm: 10.8.2
Anything else?
No response