-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
default
and defaultDev
should pass the validator like a normal value, then there's no reason to put something else than string.
Here's an example:
const toArray = makeValidator((input: string): string[] => {
return input.split(',')
})
interface IEnv {
readonly TEST: string[]
}
const env: IEnv = cleanEnv(process.env, {
TEST: toArray({default: 'test,string'}) // Argument type {default: string} is not assignable to parameter type Spec<string[]> | undefined
})
const env2: IEnv = cleanEnv(process.env, {
TEST: toArray({default: ['test','string']}) // input.split is not a function
})
This make the library inconsistent, in fact env inputs are always string and we parse them to type them correctly, we cannot trust default values and have to check them like regular env input, then default
and defaultDev
must be type of string and nothing else.
Metadata
Metadata
Assignees
Labels
No labels