Sha256: ddb0a4202a7a3b78123fe137a6d679290fe57a7fc068b1668374863e568ed3e4
Contents?: true
Size: 745 Bytes
Versions: 48
Compression:
Stored size: 745 Bytes
Contents
/* eslint-disable strict, no-param-reassign */ 'use strict'; const fs = require('fs'); const path = require('path'); const Ajv = require('ajv'); const errors = require('ajv-errors'); const keywords = require('ajv-keywords'); const ValidationError = require('./ValidationError'); const ajv = new Ajv({ allErrors: true, jsonPointers: true, }); errors(ajv); keywords(ajv, ['instanceof', 'typeof']); const validateOptions = (schema, options, name) => { if (typeof schema === 'string') { schema = fs.readFileSync(path.resolve(schema), 'utf8'); schema = JSON.parse(schema); } if (!ajv.validate(schema, options)) { throw new ValidationError(ajv.errors, name); } return true; }; module.exports = validateOptions;
Version data entries
48 entries across 26 versions & 9 rubygems