You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On arrayB: a and b are required if arrayA includes 1.
On arrayB: c is required if arrayB length is bigger then 1.
array().when('arrayA', { // this is working!
is: arrayA => arrayA.includes(1),
then: array().of(object().shape({a: string().required(), b: string().required() })),
}).when('arrayB', { // this is not working! How do I get the value of arrayB here?
is: arrayB => arrayB.length > 1,
then: array().of(object().shape({ c: string().required() })),
});
The text was updated successfully, but these errors were encountered:
royipressburger
changed the title
how to do: when on array length n
How to validate: when on array is length n
Jul 4, 2019
array().when('arrayA', { // this is working!
is: arrayA => arrayA.includes(1),
then: array().of(object().shape({a: string().required(), b: string().required() })),
}).when({ // just pass the object as first argument and is function will get arrayB
is: arrayB => arrayB.length > 1,
then: array().of(object().shape({ c: string().required() })),
});
Hi
I have the next object:
I would like to validate that:
arrayB
:a
andb
are required ifarrayA
includes 1.arrayB
:c
is required ifarrayB
length is bigger then 1.The text was updated successfully, but these errors were encountered: