I need to validate an array of numbers when a boolean is checked and i'm getting this error in console:
Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
at yupToFormErrors (formik.esm.js:701)
and this is my yup validationSchema.
export default yup.object<myFormikForm.FormValues>({
allowOther: yup.boolean(),
arrayNumbers: yup
.array<number, *>(
yup
.number()
.nullable(true)
.transform((value, originalValue) =>
originalValue === '' ? null : value,
)
.min(
minSize,
oneLine`
Must be greater or equal than
0
`,
),
)
.when('allowOther', (allowOther: boolean, schema) =>
allowOther
? schema
: schema
.required('Required')
.test(
'hasAtLeastOneValue',
'Specify at least one value',
value =>
Array.isArray(value) ? value.some(Number.isFinite) : true,
),
),
});
by the way the form is working properly but i wanna to get rid of this error, any thoughts? Thanks.