formik

Create dynamic Yup validation schema from JSON

ぐ巨炮叔叔 提交于 2020-12-01 09:47:36
问题 I'm trying to use Yup along with Formik in my react form. The form fields are going to be dynamic so as their validations. export const formData = [ { id: "name", label: "Full name", placeholder: "Enter full name", type: "text", required: true, value: "User name", values: [], validations: [ { type: "minLength", value: "5", error_message: "name should be atleast 5 char long" }, { type: "maxLength", value: "10", error_message: "name should be atleast 5 char long" } ] }, { id: "email", label: