使用Formik+Yup实现表单提交以及验证

validationSchema change depending on form values

 yup.lazy((values) => {
      const isCPF = values.docType === 'cpf'

      return yup.object().shape({
        docType: yup.string(),
        number: isCPF ? yup.string().cpf() : yup.string().cnpj()
      })
    })}
    onSubmit={loadPlanActivation}
    render={this.renderForm}
  />

validationSchema change depending on form values #1228

你可能感兴趣的:(前端,javascript)