Conditionally required schema field
See original GitHub issueIs it possible? Smth like this:
const schema = yup.object({
username: yup.string().conditionallyRequired(someVar === anotherVar)
})
Issue Analytics
- State:
- Created 7 years ago
- Reactions:21
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Applying Subschemas Conditionally - JSON Schema
The dependentSchemas keyword conditionally applies a subschema when a given property is present. This schema is applied in the same way allOf applies...
Read more >jsonSchema attribute conditionally required - Stack Overflow
I can think of four different ways to conditionally require a field. Dependencies. The dependentSchemas keyword is a conditional way to apply a ......
Read more >How to implement conditional required field validation
Hi, I am trying to implement condition based required validation. But its not working. I have dropdown with values circle, square and rectangle....
Read more >Applying subschemas conditionally | Opis JSON Schema
This is a conditional structure containing three keywords: if , then and else . Every keyword value must be a valid JSON schema...
Read more >Field required based on condition · Issue #539 · json-schema ...
It is very common to have data structures in which a field becomes required only if a particular condition holds.
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
@nilamsavani91 You want something like this:
See more here https://github.com/jquense/yup#mixedwhenkeys-string--arraystring-builder-object--value-schema-schema-schema
Thank you. I’ve already achieved it with the following code: