`Controller` should also pass down validation state and errors to input-component
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m using react-native and Controller
to wrap my UI-components. As far as I have understood the docs input-components and error messages are handled as two independent things. From an UI/UX perspective an input-component should represent itself its valid state, p.ex. a red border for an TextInput or a green check-mark after a valid edition. Thus a input-component could be in one of the following states:
- untouched (with or without value)
- positively validated (a validation was successful)
- error (a validation failed)
The validation occurs like described for mode
and reValidationMode
.
Currently I could somehow pass errors
from useForm
down to the component, but then I need a possibility to resolve name
to the associated entry (with message
) in the errors
object.
Currently I don’t know how to get a this-input-was-successful-validated state.
Describe the solution you’d like
I suggest to add error
to the props which are passed to register
. error
is null
or an object (coming from useForm:errors
). This way the input-component can access p.ex. error.message
to adopt the look-and-feel of the component
I suggest to add validated
to the props which are passed to register
. validated
is true
if and only if the input was validated successfully and was not changed since then (also depends on validation mode settings).
Describe alternatives you’ve considered see above
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
I should be awesome ! Furthermore it would be very useful to be able to watch errors as we do with values via
useWatch
(I have very large forms in which i wan’t to display error for each field without re-rendering the whole form)good point @voxspox
hasError
👍