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.
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.
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.