diff --git a/examples/Arrays.js b/examples/Arrays.js index 7afc8b25a..02cbb1b97 100644 --- a/examples/Arrays.js +++ b/examples/Arrays.js @@ -27,7 +27,7 @@ const SignIn = () => (
{values.friends.length > 0 && values.friends.map((friend, index) => ( -
+
( type="text" /> {errors.friends && + errors.friends[index] && errors.friends[index].name && touched.friends && touched.friends[index].name && ( @@ -52,6 +53,7 @@ const SignIn = () => ( type="email" /> {errors.friends && + errors.friends[index] && errors.friends[index].email && touched.friends && touched.friends[index].email && ( diff --git a/src/Formik.tsx b/src/Formik.tsx index 230311ab8..44186dc0b 100644 --- a/src/Formik.tsx +++ b/src/Formik.tsx @@ -774,18 +774,17 @@ export function yupToFormErrors(yupError: any): FormikErrors { /** * Validate a yup schema. */ -export function validateYupSchema( - data: T, +export function validateYupSchema( + values: T, schema: any, sync: boolean = false, context: any = {} -): Promise { - let validateData: any = {}; - for (let k in data) { - if (data.hasOwnProperty(k)) { +): Promise> { + let validateData: Partial = {}; + for (let k in values) { + if (values.hasOwnProperty(k)) { const key = String(k); - validateData[key] = - (data as any)[key] !== '' ? (data as any)[key] : undefined; + validateData[key] = values[key] !== '' ? values[key] : undefined; } } return schema[sync ? 'validateSync' : 'validate'](validateData, {