𝗗𝗲𝗳𝗶𝗻𝗲 𝗢𝗻𝗰𝗲, 𝗧𝗿𝘂𝘀𝘁 𝗘𝘃𝗲𝗿𝘆𝘄𝗵𝗲𝗿𝗲

CtroEnv uses four core validator factories to keep your environment variables safe.

Here is how they work:

Useful tools for every validator:

• .default(value) - Sets a fallback if the variable is missing. • .optional() - Allows the variable to be undefined. • .secret() - Masks sensitive data in your logs. • .describe(text) - Adds documentation for your error messages. • .validate(fn) - Lets you write custom logic for one-off rules.

CtroEnv works across different environments:

When validation fails, CtroEnv does not just stop. It collects every single error and shows them all at once. You get a clear list of what is missing, what has the wrong type, and what failed your custom rules.

This keeps your configuration immutable and your runtime predictable.

Source: https://dev.to/ctrotech/define-once-trust-everywhere-ctroenv-deep-dive-3bjl