Open
Description
Sometimes when we implement validated form - we need a way to check if field is valid to show it to user.
Something like this:
[password] ✅
Right now we have useForm
composable, which allow us to check if field is valid from context of form, but this way
- is not intuitive (I want to ask about input, not form) and input actually could have all validation features without a form wrapper;
- and
useForm().fields[].isValid
doesn't account for dirty state - it's true until validation is run at least once.
Here are a couple of ideas I have (don't take these at face value and perform due investigation on your own):
- make
useFormElement
composable, that would work similarly touseForm
, allowing user to access validation features from ref - update
useForm().fields
to haveisDirty
param. - maybe for
isValid
- have a third option (null
?) for case when validation wasn't run yet. That might not integrate with existing system at all though.
I believe end goal should be ability to use it something like this:
<va-input
stateful
ref="password"
:success="password.isValid"
:rules="passwordRules"
/>
const password = useFormElement('password')