Field Validation API #8253
nathanforce
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey!
I'm having a hard time getting my desired field validation behavior out of the current form constraints API and based on some issues I've found here it seems others may be, too. I wanted to open a discussion to get clarity on the intent of the behavior and, if possible, a suggested path forward (acknowledging that maybe I need to fork the repo).
What I'm trying to do
Similar to #6983, I'd like to have more control over the end user experience when interacting with invalid fields. Specifically:
validate
functionWhat isn't working
I'm stuck between a few choices here. Behavior wise, I mostly want
validationBehavior="native"
, except that I want to control what happens with the error as a user interacts with the field after the error is shown. Since I want to control this behavior I'm forced to usevalidationBehavior="aria"
and reimplement the submit-blocking behavior myself.However, if I go this path I'm not able to validate required fields before submission if they're empty/null, as react-aria stopped calling validation on empty fields in 1.5.0 (See #7715). Per this tweet from @devongovett, I should be able to use a combination of
isRequired
andvalidate
, but in my testing,isRequired
does nothing when usingvalidationBehavior="aria"
.I suppose my questions are:
If it helps, the API I'm trying to standardize around is having all of my various Field components accept a
constraints={[]}
prop where each item is a function. This was working well until 1.5.0.Thank you for all y'all have done here! Happy to provide any more details or jump on a call.
Beta Was this translation helpful? Give feedback.
All reactions