-
Using
Having this schema const TournamentSchema = object({
TournamentID: number().defined().required(),
LeagueID: number().defined().required(),
League: LeagueSchema.defined().required(),
SeasonID: number().defined().required(),
Season: SeasonSchema.defined().required(),
Name: string().defined().required().min(1),
}) When using As soon as I am using this kind of resolver from the docs, I can see all errors in the console output
Then in render
Now the situation is totally normal, but why is the error object empty ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Can you share a reproducible example vi CodeSandbox please? |
Beta Was this translation helpful? Give feedback.
-
Please read carefully the documentation Error can only be mapped if it was registered with react-hook-form. In your example, even with built-in yup resolver or your custom yup resolver, there is only one input "Name" has been registered, therefore react-hook-form cannot validate and show error of what it does not know. |
Beta Was this translation helpful? Give feedback.
-
I have the same issue, and maybe I misunderstand something, but I cannot solve this issue on this form. I have simple a resolver: yupResolver(
yup
.object()
.shape({
withdrawalType: yup
.string()
.required(t('resources.users.edit.withdrawal.dialog.validation.type')),
})
.required(),
) And I have only one input field what is a MUI `ButtonGroup ̇, and when I see this code's output: const { watch, getFieldState, getValues } = useFormContext();
const { dirtyFields, isValid } = useFormState();
console.log(
watch(),
isValid,
getFieldState('withdrawalType'),
); I got this: Object { withdrawalType: "/api/withdrawal_types/2" }
false
Object { invalid: false, isDirty: true, isTouched: true, isValidating: false, error: undefined } My question is, what have I missed? (Now, I have a workaround for this, to see all field states...) |
Beta Was this translation helpful? Give feedback.
@iongion
Please read carefully the documentation
Error can only be mapped if it was registered with react-hook-form. In your example, even with built-in yup resolver or your custom yup resolver, there is only one input "Name" has been registered, therefore react-hook-form cannot validate and show error of what it does not know.