-
Notifications
You must be signed in to change notification settings - Fork 940
Closed
Description
Describe the bug
Hi I am getting a cyclic dependency error when using pick()in combination with shape() in yup 1.2.0. The problem seems similar to #1969
To Reproduce
import { object, string } from 'yup';
const testObject = {
a1: undefined,
a2: 'over9000',
};
const a1 = string().when('a2', {
is: undefined,
then: (schema) => schema.required(),
});
const a2 = string().when('a1', {
is: undefined,
then: (schema) => schema.required(),
});
const schema = object({ a3: string().required(), a4: string().required() }).shape({ a1, a2 }, [
['a1', 'a2'],
]);
const isValid = schema.pick(['a1', 'a2']).isValid(testObject);Here is a very basic demo showing the resulting error: https://plnkr.co/edit/Nbdwma2bEbtSrxje
The resulting error is:
Error: Cyclic dependency, node was:"a2"
Expected behavior
The schema is able to validate properly for the picked fields.
Platform (please complete the following information):
- Yup 1.2.0
Metadata
Metadata
Assignees
Labels
No labels