19

これが私の検証スキーマです:

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ます。検証を条件付きで機能させる方法、たとえばisPersontrue の場合、person検証validationSchemaが必要な場合は?

4

5 に答える 5