rjsf-team/react-jsonschema-form

Cannot check for existing errors on field in CustomValidate

Open

#4.284 aberto em 30 de ago. de 2024

Ver no GitHub
 (7 comments) (0 reactions) (1 assignee)TypeScript (2.136 forks)batch import
featurehelp wanted

Métricas do repositório

Stars
 (13.175 stars)
Métricas de merge de PR
 (Mesclagem média 3d 17h) (32 fundiu PRs em 30d)

Description

Prerequisites

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

Guia do colaborador