UNPKG

980 BJavaScriptView Raw
1/**
2 * @fileoverview The instance of Ajv validator.
3 * @author Evgeny Poberezkin
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Requirements
9//------------------------------------------------------------------------------
10
11const Ajv = require("ajv"),
12 metaSchema = require("ajv/lib/refs/json-schema-draft-04.json");
13
14//------------------------------------------------------------------------------
15// Public Interface
16//------------------------------------------------------------------------------
17
18module.exports = (additionalOptions = {}) => {
19 const ajv = new Ajv({
20 meta: false,
21 useDefaults: true,
22 validateSchema: false,
23 missingRefs: "ignore",
24 verbose: true,
25 schemaId: "auto",
26 ...additionalOptions
27 });
28
29 ajv.addMetaSchema(metaSchema);
30 // eslint-disable-next-line no-underscore-dangle
31 ajv._opts.defaultMeta = metaSchema.id;
32
33 return ajv;
34};