constructor(schema, ajvSettings) { // Used default values if arguments not supplied schema = schema || defaultSchema; ajvSettings = ajvSettings || defaultAJVSettings; this.ajv = new Ajv(ajvSettings); // To use Ajv with draft-06 schemas you need to explicitly add the meta-schema to the validator instance: this.ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')); this.schema = schema; this.validator = this.ajv.compile(this.schema); }
constructor(schema, ajvSettings) { // Used default values if arguments not supplied schema = schema || defaultSchema; ajvSettings = ajvSettings || defaultAJVSettings; this.ajv = new Ajv(ajvSettings); // To use Ajv with draft-06 schemas you need to explicitly add the meta-schema to the validator instance: this.ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')); this.schema = schema; this.validator = this.ajv.compile(this.schema); }