|
2 | 2 | if (typeof exports === 'object' && typeof module !== 'undefined') { |
3 | 3 | const jsonlint = require('./jsonlint') |
4 | 4 | const ajv = { |
5 | | - AjvOld: 'ajv6', |
| 5 | + Ajv04: 'ajv-draft-04', |
6 | 6 | Ajv07: 'ajv', |
7 | 7 | AjvJTD: 'ajv/dist/jtd', |
8 | 8 | Ajv2019: 'ajv/dist/2019', |
9 | 9 | Ajv2020: 'ajv/dist/2020', |
10 | | - Schema04: 'ajv6/lib/refs/json-schema-draft-04.json', |
11 | 10 | Schema06: 'ajv/dist/refs/json-schema-draft-06.json' |
12 | 11 | } |
13 | 12 | const requireAjv = name => { |
|
16 | 15 | } |
17 | 16 | factory(exports, jsonlint, requireAjv) |
18 | 17 | } else if (typeof define === 'function' && define.amd) { |
19 | | - define('jsonlint-validator', ['exports', 'jsonlint', 'ajv', 'ajv7'], |
20 | | - function (exports, jsonlint, ajv, ajv7) { |
| 18 | + define('jsonlint-validator', ['exports', 'jsonlint', 'ajv'], |
| 19 | + function (exports, jsonlint, ajv) { |
21 | 20 | const requireAjv = name => { |
22 | | - if (name === 'AjvOld') return ajv |
23 | | - const exported = ajv7[name] |
| 21 | + const exported = ajv[name] |
24 | 22 | return !exported.$schema && exported.default || exported |
25 | 23 | } |
26 | 24 | factory(exports, jsonlint, requireAjv) |
27 | 25 | }) |
28 | 26 | } else { |
29 | 27 | global = global || self |
30 | 28 | const requireAjv = name => { |
31 | | - if (name === 'AjvOld') return global.Ajv |
32 | | - const exported = global.ajv7[name] |
| 29 | + const exported = global.ajv[name] |
33 | 30 | return !exported.$schema && exported.default || exported |
34 | 31 | } |
35 | 32 | factory(global.jsonlintValidator = {}, global.jsonlint, requireAjv) |
|
114 | 111 | const Ajv = requireAjv('Ajv07') |
115 | 112 | ajv = new Ajv() |
116 | 113 | } else if (environment === 'json-schema-draft-04' || environment === 'draft-04') { |
117 | | - const Ajv = requireAjv('AjvOld') |
118 | | - ajv = new Ajv({ schemaId: 'id' }) |
119 | | - ajv.addMetaSchema(requireAjv('Schema04')) |
| 114 | + const Ajv = requireAjv('Ajv04') |
| 115 | + ajv = new Ajv() |
120 | 116 | } else if (environment === 'json-schema-draft-2019-09' || environment === 'draft-2019-09') { |
121 | 117 | const Ajv = requireAjv('Ajv2019') |
122 | 118 | ajv = new Ajv() |
|
0 commit comments