How to use the ajv-keywords/keywords/typeof function in ajv-keywords

To help you get started, we’ve selected a few ajv-keywords 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 zerobias / telegram-mtproto / src / service / main / config-validation.js View on Github external
additionalProperties: false
}

const schema = {
  properties: {
    app,
    api,
    server,
    schema  : type.obj,
    mtSchema: type.obj
  },
  additionalProperties: false
}

const ajv = new Ajv()
AjvKeys(ajv)
const validate = ajv.compile(schema)

const configValidator = config => {
  const valid = validate(config)
  if (!valid) {
    console.log('config errors')
    validate.errors.map(printObj)
    throw new Error('wrong config fields')
  }
}

const canDir = propIs(Function, 'dir', console)
const printObj = canDir
  ? (arg) => console.dir( arg, { colors: true })
  : (arg) => console.log(arg)

ajv-keywords

Additional JSON-Schema keywords for Ajv JSON validator

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis