#Do validators work with nested fields

15 messages · Page 1 of 1 (latest)

crimson path
#

I'm trying to use the new validators functions with nested fields in a form like shown in the image but no error are displayed for the inputs

viral delta
crimson path
#

hmm do input need to be inside a form html element to work

viral delta
crimson path
#

yep true, although i m using form.validateField('presence')

#

or could it be bcz I'm passing form as a prop

#

so this works const {hasError, error} = form.validateField("presence.nom")

#

but using the parent object does not const {hasError, error} = form.validateField("presence")

#

so when using form.validateField() you should specify exactly the field not the parent or else no error will be displayed in the in the input

#

@viral delta know any work around for this

viral delta
crimson path
#

will was hoping to validate each section and kinda make it a little bit easy for me hhh

#

@viral delta so looking in react dev tools component state is look like the useForm hook does have an Error when selecting the parent object the one to be validated using validateField() it just has one error only though hope that helps