How to use the envalid.host function in envalid

To help you get started, we’ve selected a few envalid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / envalid_v4.x.x / flow_v0.104.x- / test_envalid_v4.x.x.js View on Github external
host,
  json,
  port,
  num,
  str,
  url,
  type ValidatorSpec
} from 'envalid'

const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()

const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
  NODE_ENV: str()
})

// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
  NODE_ENV: str()
})

// $ExpectError
const invalidBooleanValidatorSpec: ValidatorSpec = bool()