%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
import Ajv, {AnySchema, AnyValidateFunction, ErrorObject} from "../core" import standaloneCode from "." import * as requireFromString from "require-from-string" export default class AjvPack { errors?: ErrorObject[] | null // errors from the last validation constructor(readonly ajv: Ajv) {} validate(schemaKeyRef: AnySchema | string, data: unknown): boolean | Promise<unknown> { return Ajv.prototype.validate.call(this, schemaKeyRef, data) } compile<T = unknown>(schema: AnySchema, meta?: boolean): AnyValidateFunction<T> { return this.getStandalone(this.ajv.compile<T>(schema, meta)) } getSchema<T = unknown>(keyRef: string): AnyValidateFunction<T> | undefined { const v = this.ajv.getSchema<T>(keyRef) if (!v) return undefined return this.getStandalone(v) } private getStandalone<T = unknown>(v: AnyValidateFunction<T>): AnyValidateFunction<T> { return requireFromString(standaloneCode(this.ajv, v)) as AnyValidateFunction<T> } addSchema(...args: Parameters<typeof Ajv.prototype.addSchema>): AjvPack { this.ajv.addSchema.call(this.ajv, ...args) return this } addKeyword(...args: Parameters<typeof Ajv.prototype.addKeyword>): AjvPack { this.ajv.addKeyword.call(this.ajv, ...args) return this } }