Handling Conditional Defaults in API Schema Parsing
I am parsing a schema for an api endpoint it has some optional options with defaults
however, there is one specific scenario where based on a condition I determine sometime after parsing I need to know whether a value was provided or from the default
basically if the condition is true I first need to check if
the solutions I have thought of are:
1. use
2. create a schema that requires some services that inject the
thoughts appriciated
however, there is one specific scenario where based on a condition I determine sometime after parsing I need to know whether a value was provided or from the default
basically if the condition is true I first need to check if
foo was provided in the body, if not then look at another optional thing, and then finally use the default value of the schemathe solutions I have thought of are:
1. use
S.optionalToRequired and map the T | undefined to { value: T, provided: boolean }2. create a schema that requires some services that inject the
otherThing and the condition and inject them and use the result of that special schema in this specific scenariothoughts appriciated
