1 | import type {AnySchemaObject} from "./types"
|
---|
2 | import AjvCore from "./core"
|
---|
3 | import draft7Vocabularies from "./vocabularies/draft7"
|
---|
4 | import discriminator from "./vocabularies/discriminator"
|
---|
5 | import * as draft7MetaSchema from "./refs/json-schema-draft-07.json"
|
---|
6 |
|
---|
7 | const META_SUPPORT_DATA = ["/properties"]
|
---|
8 |
|
---|
9 | const META_SCHEMA_ID = "http://json-schema.org/draft-07/schema"
|
---|
10 |
|
---|
11 | class Ajv extends AjvCore {
|
---|
12 | _addVocabularies(): void {
|
---|
13 | super._addVocabularies()
|
---|
14 | draft7Vocabularies.forEach((v) => this.addVocabulary(v))
|
---|
15 | if (this.opts.discriminator) this.addKeyword(discriminator)
|
---|
16 | }
|
---|
17 |
|
---|
18 | _addDefaultMetaSchema(): void {
|
---|
19 | super._addDefaultMetaSchema()
|
---|
20 | if (!this.opts.meta) return
|
---|
21 | const metaSchema = this.opts.$data
|
---|
22 | ? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA)
|
---|
23 | : draft7MetaSchema
|
---|
24 | this.addMetaSchema(metaSchema, META_SCHEMA_ID, false)
|
---|
25 | this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID
|
---|
26 | }
|
---|
27 |
|
---|
28 | defaultMeta(): string | AnySchemaObject | undefined {
|
---|
29 | return (this.opts.defaultMeta =
|
---|
30 | super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined))
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | module.exports = exports = Ajv
|
---|
35 | Object.defineProperty(exports, "__esModule", {value: true})
|
---|
36 |
|
---|
37 | export default Ajv
|
---|
38 |
|
---|
39 | export {
|
---|
40 | Format,
|
---|
41 | FormatDefinition,
|
---|
42 | AsyncFormatDefinition,
|
---|
43 | KeywordDefinition,
|
---|
44 | KeywordErrorDefinition,
|
---|
45 | CodeKeywordDefinition,
|
---|
46 | MacroKeywordDefinition,
|
---|
47 | FuncKeywordDefinition,
|
---|
48 | Vocabulary,
|
---|
49 | Schema,
|
---|
50 | SchemaObject,
|
---|
51 | AnySchemaObject,
|
---|
52 | AsyncSchema,
|
---|
53 | AnySchema,
|
---|
54 | ValidateFunction,
|
---|
55 | AsyncValidateFunction,
|
---|
56 | SchemaValidateFunction,
|
---|
57 | ErrorObject,
|
---|
58 | ErrorNoParams,
|
---|
59 | } from "./types"
|
---|
60 |
|
---|
61 | export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
|
---|
62 | export {SchemaCxt, SchemaObjCxt} from "./compile"
|
---|
63 | export {KeywordCxt} from "./compile/validate"
|
---|
64 | export {DefinedError} from "./vocabularies/errors"
|
---|
65 | export {JSONType} from "./compile/rules"
|
---|
66 | export {JSONSchemaType} from "./types/json-schema"
|
---|
67 | export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen"
|
---|