main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
993 bytes
|
Rev | Line | |
---|
[d565449] | 1 | /**
|
---|
| 2 | * @fileoverview The instance of Ajv validator.
|
---|
| 3 | * @author Evgeny Poberezkin
|
---|
| 4 | */
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | //------------------------------------------------------------------------------
|
---|
| 8 | // Requirements
|
---|
| 9 | //------------------------------------------------------------------------------
|
---|
| 10 |
|
---|
| 11 | const Ajv = require("ajv"),
|
---|
| 12 | metaSchema = require("ajv/lib/refs/json-schema-draft-04.json");
|
---|
| 13 |
|
---|
| 14 | //------------------------------------------------------------------------------
|
---|
| 15 | // Public Interface
|
---|
| 16 | //------------------------------------------------------------------------------
|
---|
| 17 |
|
---|
| 18 | module.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 -- Ajv's API
|
---|
| 31 | ajv._opts.defaultMeta = metaSchema.id;
|
---|
| 32 |
|
---|
| 33 | return ajv;
|
---|
| 34 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.