valienv
Version:
A simple environment variables validator for Node.js, web browsers and React Native
16 lines (15 loc) • 640 B
TypeScript
export type Validator<T> = (value: string | undefined) => T | undefined;
export type OptionalEnvValue<T> = {
defined: true;
value: T;
} | {
defined: false;
};
export declare const boolean: Validator<boolean>;
export declare const email: Validator<string>;
export declare const number: Validator<number>;
export declare const port: Validator<number>;
export declare const string: Validator<string>;
export declare const url: Validator<string>;
export declare const oneOf: <T extends string>(...values: Readonly<T[]>) => Validator<T>;
export declare const optional: <T>(validator: Validator<T>) => Validator<OptionalEnvValue<T>>;