これが私の検証スキーマです:
const validationSchema = Yup.object().shape({
person: Yup.object().shape({
name: Yup.string().required('Field is required'),
surname: Yup.string().required('Field is required'),
middleName: Yup.string().required('Field is required'),
email: Yup.string()
.email('Wrong e-mail format')
.required('Field is required')
}),
company: Yup.object().shape({
name: Yup.string().required('Field is required'),
address: Yup.string().required('Field is required'),
email: Yup.string()
.email('Wrong e-mail format')
.required('Field is required')
})
});
また、React State には と の 2 つの変数がisPerson
ありisCompany
ます。検証を条件付きで機能させる方法、たとえばisPerson
true の場合、person
検証validationSchema
が必要な場合は?