source: trip-planner-front/node_modules/ajv/lib/2020.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.0 KB
Line 
1import type {AnySchemaObject} from "./types"
2import AjvCore, {Options} from "./core"
3
4import draft2020Vocabularies from "./vocabularies/draft2020"
5import discriminator from "./vocabularies/discriminator"
6import addMetaSchema2020 from "./refs/json-schema-2020-12"
7
8const META_SCHEMA_ID = "https://json-schema.org/draft/2020-12/schema"
9
10class Ajv2020 extends AjvCore {
11 constructor(opts: Options = {}) {
12 super({
13 ...opts,
14 dynamicRef: true,
15 next: true,
16 unevaluated: true,
17 })
18 }
19
20 _addVocabularies(): void {
21 super._addVocabularies()
22 draft2020Vocabularies.forEach((v) => this.addVocabulary(v))
23 if (this.opts.discriminator) this.addKeyword(discriminator)
24 }
25
26 _addDefaultMetaSchema(): void {
27 super._addDefaultMetaSchema()
28 const {$data, meta} = this.opts
29 if (!meta) return
30 addMetaSchema2020.call(this, $data)
31 this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID
32 }
33
34 defaultMeta(): string | AnySchemaObject | undefined {
35 return (this.opts.defaultMeta =
36 super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined))
37 }
38}
39
40module.exports = exports = Ajv2020
41Object.defineProperty(exports, "__esModule", {value: true})
42
43export default Ajv2020
44
45export {
46 Format,
47 FormatDefinition,
48 AsyncFormatDefinition,
49 KeywordDefinition,
50 KeywordErrorDefinition,
51 CodeKeywordDefinition,
52 MacroKeywordDefinition,
53 FuncKeywordDefinition,
54 Vocabulary,
55 Schema,
56 SchemaObject,
57 AnySchemaObject,
58 AsyncSchema,
59 AnySchema,
60 ValidateFunction,
61 AsyncValidateFunction,
62 ErrorObject,
63 ErrorNoParams,
64} from "./types"
65
66export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
67export {SchemaCxt, SchemaObjCxt} from "./compile"
68export {KeywordCxt} from "./compile/validate"
69export {DefinedError} from "./vocabularies/errors"
70export {JSONType} from "./compile/rules"
71export {JSONSchemaType} from "./types/json-schema"
72export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen"
Note: See TracBrowser for help on using the repository browser.