How to require either one of two fields? (Cyclic dependency error)
See original GitHub issueWhat (if possible) is the correct way to define that either the email or phone is a string > 1?
var formModelSchema = yup.object({
email: yup.string().email().when('phone', {
is: (phone) => !phone || phone.length === 0,
then: yup.string().email().required(),
otherwise: yup.string()
}),
phone: yup.string().when('email', {
is: (email) => !email || email.length === 0,
then: yup.string().required(),
otherwise: yup.string()
})
});
Uncaught (in promise) Error: Cyclic dependency: "phone"
Issue Analytics
- State:
- Created 7 years ago
- Reactions:28
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Yup validate either one of two fields is required (one of them is ...
You can achieve this by creating a type that is interdepedent on related_items_id and short_desc export interface BaseType { title: string; ...
Read more >yup: Conditional Validation & Cyclic Dependency Error Fix
You have 3 fields in a form: is_mobile_app , ios_id and android_id . If is_mobile_app is false, then both ios_id and android_id both...
Read more >How to validate two fields that depend on each other with Yup
Solution: const yup = require('yup') const { setLocale } = yup setLocale({ mixed: { notType: 'the ${path} is obligatory', required: 'the field ......
Read more >How to fix the “Circular dependency detected” error in Google ...
The "Circular dependency detected" error in Google Sheets, is a very common error that can occur when using almost any formula.
Read more >Avoiding circular dependency errors in DAX - SQLBI
If your code looks correct, that is if you do not see any obvious circular dependencies, then there are two possible causes for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had to use
yup.object().shape({...})
with @GeoffreyHervet solution to avoid cyclic dependency error.