npmtest-auto-install (v0.0.1)

Code coverage report for node-npmtest-auto-install/auto-install/node_modules/har-validator/lib/runner.js

Statements: 36.36% (4 / 11)      Branches: 0% (0 / 6)      Functions: 0% (0 / 1)      Lines: 36.36% (4 / 11)      Ignored: none     

All files » node-npmtest-auto-install/auto-install/node_modules/har-validator/lib/ » runner.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31    1 1 1   1                                                
'use strict'
 
var schemas = require('./schemas')
var ValidationError = require('./error')
var validator = require('is-my-json-valid')
 
module.exports = function (schema, data, cb) {
  // default value
  var valid = false
 
  // validator config
  var validate = validator(schema, {
    greedy: true,
    verbose: true,
    schemas: schemas
  })
 
  // execute is-my-json-valid
  if (data !== undefined) {
    valid = validate(data)
  }
 
  // callback?
  if (typeof cb === 'function') {
    return cb(validate.errors ? new ValidationError(validate.errors) : null, valid)
  }
 
  return valid
}