• Validate a configuration object and return a frozen copy.

    Type Parameters

    • T

    Parameters

    • obj: T

    Returns CleanFrozenConfig<T>

    Example

    export const config = validate(configDef);
    export const dirtyConfig = validate(configDef, 'dont-throw');

    In the first form, this function will throw an error if the configuration is invalid. In the second form, it will return a ConfigResult object that can be inspected for errors.

    NOTE: THE 'ERROR' SIDE OF THE RESPONSE FROM THE SECOND FORM IS DANGEROUS. We want the option to not throw on config errors, but we also don't want to have to use type-guards to handle bad config throughout our entire codebase. This type is a dangerous compromise that allows us to blindly use values as if they were valid, while knowing that they may not be.

  • Type Parameters

    • T

    Parameters

    • obj: T
    • behavior: "dont-throw"

    Returns ConfigResult<T>

Generated using TypeDoc