Runtime vs. Startup Validation of Environment Variables: Best Practices and Patterns

Rookie developer here - I was wondering, what are the reasons for validating environment variables during runtime, as opposed to solely at application startup? Given that these variables wouldn't normally change without deliberate action, is runtime validation really "worth" it? (mainly considering more intricate configs here, that might be more computationally expensive)

Also, let's say I have created these configs:

import { Config } from "effect";

export const PrismaConfig = Config.all({
    databaseUrl: Config.string("DATABASE_URL")
}).pipe(Config.nested("PRISMA"));

export const CookieConfig = Config.all({
    cookieSecret: Config.string("SECRET")
}).pipe(Config.nested("COOKIE"));


Would the pattern to use be to both validate these at startup in some mega-config, and also in the services consuming them? And if yes to the startup validation, what'd be the pattern for doing this?
Was this page helpful?