Open supermoos opened 7 years ago
@supermoos I'm not sure your code is written to meet your goal. As you wrote it, only an object instance is required. name: null
would have to occur before you received Full name is required
.
If you want Full name is required
when either first or last name is missing, just add that to those fields.
formModelSchema = yup.object({
name: yup.object({
first: yup.string().min(2).required('Full name is required'),
middle: yup.string(),
last: yup.string().min(2).required('Full name is required')
}),
email: yup.string().email().required('E-mail input is required')
});
How would you set an error message for a structure like:
So that if for example first,name was input correctly but last.name was missing the error message would be: 'Full name is required'