source: trip-planner-front/node_modules/ajv/lib/2019.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 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
13class 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
47Object.defineProperty(exports, "__esModule", {value: true})
48
49export default Ajv2019
50
51export {
52 Format,
53 FormatDefinition,
54 AsyncFormatDefinition,
55 KeywordDefinition,
56 KeywordErrorDefinition,
57 CodeKeywordDefinition,
58 MacroKeywordDefinition,
59 FuncKeywordDefinition,
60 Vocabulary,
61 Schema,
62 SchemaObject,
63 AnySchemaObject,
64 AsyncSchema,
65 AnySchema,
66 ValidateFunction,
67 AsyncValidateFunction,
68 ErrorObject,
69 ErrorNoParams,
70} from "./types"
71
72export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
73export {SchemaCxt, SchemaObjCxt} from "./compile"
74export {KeywordCxt} from "./compile/validate"
75export {DefinedError} from "./vocabularies/errors"
76export {JSONType} from "./compile/rules"
77export {JSONSchemaType} from "./types/json-schema"
78export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen"
Note: See TracBrowser for help on using the repository browser.