resolvers
resolvers copied to clipboard
It is not possible to use your types for Yup validation
Describe the bug How to add a custom type when not all fields are inferred from the form?
To Reproduce Steps to reproduce the behavior:
We use so props:
export type FormValues = {
account: Account;
currency: Currency;
amount: string;
};
Account and Account types have many props.
type Account {
accountId: string;
name: string;
type: Type;
...
}
account and currency fields are custom Select components.
We need to check that an element is selected.
const validationSchema = Yup.object().shape({
account: Yup.object().required('Account is required'),
currency: Yup.object().required('Currency is required'),
amount: Yup.string().required('Amount is required.')
});
Codesandbox link (Required) codesandbox link.
Expected behavior The yupResolver function should not complain about the given formSchema.
Any updates on this? We also had to downgrade to 3.1.0/couldn't upgrade to latest in our codebase, which is really unfortunate.
I have a same problem. When I have some complex type for form, sometimes I have in form values which I dont need for validation and if I have like enum as a type, then is the end. Usually I have as form type graphql input type. In this type can be as type for value null, undefined or type of value. But from yup resolver I hade a little bit another type. Value or null. This maybe is my problem.Something missing in yup validation schema (maybe optional). Now I must downgrade to version 3.1.0.