source: imaps-frontend/node_modules/ajv/lib/2019.ts@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.4 KB
Line 
1import type {AnySchemaObject} from "./types"
2import AjvCore, {Options} from "./core"
3
4import draft7Vocabularies from "./vocabularies/draft7"
5import dynamicVocabulary from "./vocabularies/dynamic"
6import nextVocabulary from "./vocabularies/next"
7import unevaluatedVocabulary from "./vocabularies/unevaluated"
8import discriminator from "./vocabularies/discriminator"
9import addMetaSchema2019 from "./refs/json-schema-2019-09"
10
11const META_SCHEMA_ID = "https://json-schema.org/draft/2019-09/schema"
12
13export class Ajv2019 extends AjvCore {
14 constructor(opts: Options = {}) {
15 super({
16 ...opts,
17 dynamicRef: true,
18 next: true,
19 unevaluated: true,
20 })
21 }
22
23 _addVocabularies(): void {
24 super._addVocabularies()
25 this.addVocabulary(dynamicVocabulary)
26 draft7Vocabularies.forEach((v) => this.addVocabulary(v))
27 this.addVocabulary(nextVocabulary)
28 this.addVocabulary(unevaluatedVocabulary)
29 if (this.opts.discriminator) this.addKeyword(discriminator)
30 }
31
32 _addDefaultMetaSchema(): void {
33 super._addDefaultMetaSchema()
34 const {$data, meta} = this.opts
35 if (!meta) return
36 addMetaSchema2019.call(this, $data)
37 this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID
38 }
39
40 defaultMeta(): string | AnySchemaObject | undefined {
41 return (this.opts.defaultMeta =
42 super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined))
43 }
44}
45
46module.exports = exports = Ajv2019
47module.exports.Ajv2019 = Ajv2019
48Object.defineProperty(exports, "__esModule", {value: true})
49
50export default Ajv2019
51
52export {
53 Format,
54 FormatDefinition,
55 AsyncFormatDefinition,
56 KeywordDefinition,
57 KeywordErrorDefinition,
58 CodeKeywordDefinition,
59 MacroKeywordDefinition,
60 FuncKeywordDefinition,
61 Vocabulary,
62 Schema,
63 SchemaObject,
64 AnySchemaObject,
65 AsyncSchema,
66 AnySchema,
67 ValidateFunction,
68 AsyncValidateFunction,
69 ErrorObject,
70 ErrorNoParams,
71} from "./types"
72
73export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
74export {SchemaCxt, SchemaObjCxt} from "./compile"
75export {KeywordCxt} from "./compile/validate"
76export {DefinedError} from "./vocabularies/errors"
77export {JSONType} from "./compile/rules"
78export {JSONSchemaType} from "./types/json-schema"
79export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen"
80export {default as ValidationError} from "./runtime/validation_error"
81export {default as MissingRefError} from "./compile/ref_error"
Note: See TracBrowser for help on using the repository browser.