Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

default and default:Dev should be of type string #155

Copy link
Copy link
@antoine-pous

Description

@antoine-pous
Issue body actions

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.