What's the intended way to create a conditional schema? #771
-
Consider the following schema: const EnvSchema = object({
CRON_SECRET: process.env.VERCEL === '1' ? string() : optional(string())
}) Basically, the idea is if the application is deployed to Vercel, ensure that The above seems to function as intended, but then I noticed |
Beta Was this translation helpful? Give feedback.
Answered by
fabian-hiller
Aug 6, 2024
Replies: 1 comment
-
Your approach is perfectly fine. I would write it the same way. You only need |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mwskwong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your approach is perfectly fine. I would write it the same way. You only need
lazy
for recursive schemas, or if you create a schema depending on the input or an external value that may change over time. Butprocess.env.VERCEL
is most likely a static value.