import { dereference } from './dereference.js'; import { validate } from './validate.js'; export class Validator { schema; draft; shortCircuit; lookup; constructor(schema, draft = '2019-09', shortCircuit = true) { this.schema = schema; this.draft = draft; this.shortCircuit = shortCircuit; this.lookup = dereference(schema); } validate(instance) { return validate(instance, this.schema, this.draft, this.lookup, this.shortCircuit); } addSchema(schema, id) { if (id) { schema = { ...schema, $id: id }; } dereference(schema, this.lookup); } }