trusty-cms 5.0.4 → 5.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +68 -68
- data/app/models/asset.rb +8 -2
- data/app/views/admin/assets/_asset_table.html.haml +1 -1
- data/app/views/admin/assets/_search.html.haml +1 -1
- data/app/views/admin/assets/_search_results.html.haml +2 -2
- data/app/views/admin/assets/edit.html.haml +5 -5
- data/app/views/admin/assets/index.html.haml +1 -1
- data/app/views/admin/configuration/_clipped_show.html.haml +1 -1
- data/app/views/admin/pages/_asset_popups.html.haml +5 -5
- data/app/views/admin/removed/_assets_bucket.html.haml +2 -2
- data/app/views/admin/removed/_assets_container.html.haml +6 -6
- data/app/views/admin/removed/_bucket.html.haml +1 -1
- data/app/views/admin/removed/_upload_to_page.html.haml +1 -1
- data/app/views/admin/sites/_form.haml +2 -2
- data/app/views/admin/snippets/edit.html.haml +1 -1
- data/app/views/admin/snippets/new.html.haml +1 -1
- data/lib/generators/extension_controller/templates/view_spec.rb +1 -1
- data/lib/generators/generator_base_extension.rb +0 -1
- data/lib/generators/instance/instance_generator.rb +1 -1
- data/lib/generators/language_extension/language_extension_generator.rb +0 -1
- data/lib/generators/language_extension/templates/test_helper.rb +0 -1
- data/lib/generators/trusty_cms/trusty_cms_generator.rb +0 -2
- data/lib/trusty_cms.rb +1 -1
- data/node_modules/ajv/README.md +158 -72
- data/node_modules/ajv/dist/ajv.bundle.js +136 -112
- data/node_modules/ajv/dist/ajv.min.js +2 -2
- data/node_modules/ajv/dist/ajv.min.js.map +1 -1
- data/node_modules/ajv/lib/ajv.d.ts +3 -1
- data/node_modules/ajv/lib/compile/equal.js +1 -1
- data/node_modules/ajv/lib/compile/formats.js +4 -4
- data/node_modules/ajv/lib/compile/index.js +1 -1
- data/node_modules/ajv/lib/compile/util.js +9 -44
- data/node_modules/ajv/lib/data.js +1 -1
- data/node_modules/ajv/lib/definition_schema.js +1 -1
- data/node_modules/ajv/lib/dot/_limit.jst +9 -0
- data/node_modules/ajv/lib/dot/_limitItems.jst +2 -0
- data/node_modules/ajv/lib/dot/_limitLength.jst +2 -0
- data/node_modules/ajv/lib/dot/_limitProperties.jst +2 -0
- data/node_modules/ajv/lib/dot/allOf.jst +0 -2
- data/node_modules/ajv/lib/dot/anyOf.jst +0 -2
- data/node_modules/ajv/lib/dot/coerce.def +18 -28
- data/node_modules/ajv/lib/dot/contains.jst +0 -2
- data/node_modules/ajv/lib/dot/definitions.def +9 -7
- data/node_modules/ajv/lib/dot/dependencies.jst +1 -2
- data/node_modules/ajv/lib/dot/if.jst +0 -2
- data/node_modules/ajv/lib/dot/items.jst +0 -2
- data/node_modules/ajv/lib/dot/multipleOf.jst +2 -0
- data/node_modules/ajv/lib/dot/properties.jst +6 -5
- data/node_modules/ajv/lib/dot/propertyNames.jst +0 -2
- data/node_modules/ajv/lib/dot/uniqueItems.jst +1 -1
- data/node_modules/ajv/lib/dot/validate.jst +3 -9
- data/node_modules/ajv/lib/dotjs/_limit.js +6 -0
- data/node_modules/ajv/lib/dotjs/_limitItems.js +3 -0
- data/node_modules/ajv/lib/dotjs/_limitLength.js +3 -0
- data/node_modules/ajv/lib/dotjs/_limitProperties.js +3 -0
- data/node_modules/ajv/lib/dotjs/allOf.js +1 -2
- data/node_modules/ajv/lib/dotjs/anyOf.js +1 -2
- data/node_modules/ajv/lib/dotjs/contains.js +1 -2
- data/node_modules/ajv/lib/dotjs/dependencies.js +2 -2
- data/node_modules/ajv/lib/dotjs/if.js +2 -3
- data/node_modules/ajv/lib/dotjs/items.js +3 -4
- data/node_modules/ajv/lib/dotjs/multipleOf.js +3 -0
- data/node_modules/ajv/lib/dotjs/not.js +1 -1
- data/node_modules/ajv/lib/dotjs/oneOf.js +1 -1
- data/node_modules/ajv/lib/dotjs/properties.js +11 -6
- data/node_modules/ajv/lib/dotjs/propertyNames.js +1 -2
- data/node_modules/ajv/lib/dotjs/required.js +1 -1
- data/node_modules/ajv/lib/dotjs/uniqueItems.js +1 -1
- data/node_modules/ajv/lib/dotjs/validate.js +13 -25
- data/node_modules/ajv/lib/keyword.js +1 -1
- data/node_modules/ajv/lib/refs/data.json +1 -1
- data/node_modules/ajv/lib/refs/json-schema-secure.json +1 -1
- data/node_modules/ajv/package.json +18 -10
- data/node_modules/ajv/scripts/info +0 -0
- data/node_modules/ajv/scripts/prepare-tests +0 -0
- data/node_modules/ajv/scripts/publish-built-version +1 -1
- data/node_modules/ajv/scripts/travis-gh-pages +1 -1
- data/node_modules/fast-deep-equal/es6/index.d.ts +1 -1
- data/node_modules/fast-deep-equal/es6/react.d.ts +1 -1
- data/node_modules/fast-deep-equal/package.json +7 -7
- data/node_modules/fast-deep-equal/react.d.ts +1 -1
- data/node_modules/uri-js/LICENSE +11 -0
- data/node_modules/uri-js/README.md +22 -18
- data/node_modules/uri-js/dist/es5/uri.all.d.ts +59 -59
- data/node_modules/uri-js/dist/es5/uri.all.js +61 -7
- data/node_modules/uri-js/dist/es5/uri.all.js.map +1 -1
- data/node_modules/uri-js/dist/es5/uri.all.min.d.ts +59 -59
- data/node_modules/uri-js/dist/es5/uri.all.min.js +2 -2
- data/node_modules/uri-js/dist/es5/uri.all.min.js.map +1 -1
- data/node_modules/uri-js/dist/esnext/index.d.ts +1 -1
- data/node_modules/uri-js/dist/esnext/index.js +16 -12
- data/node_modules/uri-js/dist/esnext/index.js.map +1 -1
- data/node_modules/uri-js/dist/esnext/regexps-iri.d.ts +3 -3
- data/node_modules/uri-js/dist/esnext/regexps-iri.js +2 -2
- data/node_modules/uri-js/dist/esnext/regexps-iri.js.map +0 -0
- data/node_modules/uri-js/dist/esnext/regexps-uri.d.ts +4 -4
- data/node_modules/uri-js/dist/esnext/regexps-uri.js +41 -41
- data/node_modules/uri-js/dist/esnext/regexps-uri.js.map +0 -0
- data/node_modules/uri-js/dist/esnext/schemes/http.d.ts +3 -3
- data/node_modules/uri-js/dist/esnext/schemes/http.js +27 -26
- data/node_modules/uri-js/dist/esnext/schemes/http.js.map +1 -1
- data/node_modules/uri-js/dist/esnext/schemes/https.d.ts +3 -3
- data/node_modules/uri-js/dist/esnext/schemes/https.js +8 -8
- data/node_modules/uri-js/dist/esnext/schemes/https.js.map +0 -0
- data/node_modules/uri-js/dist/esnext/schemes/mailto.d.ts +12 -12
- data/node_modules/uri-js/dist/esnext/schemes/mailto.js +0 -0
- data/node_modules/uri-js/dist/esnext/schemes/mailto.js.map +0 -0
- data/node_modules/uri-js/dist/esnext/schemes/urn-uuid.d.ts +7 -7
- data/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js +22 -22
- data/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js.map +0 -0
- data/node_modules/uri-js/dist/esnext/schemes/urn.d.ts +10 -10
- data/node_modules/uri-js/dist/esnext/schemes/urn.js +48 -48
- data/node_modules/uri-js/dist/esnext/schemes/urn.js.map +0 -0
- data/node_modules/uri-js/dist/esnext/schemes/ws.d.ts +7 -0
- data/node_modules/uri-js/dist/esnext/schemes/ws.js +41 -0
- data/node_modules/uri-js/dist/esnext/schemes/ws.js.map +1 -0
- data/node_modules/uri-js/dist/esnext/schemes/wss.d.ts +3 -0
- data/node_modules/uri-js/dist/esnext/schemes/wss.js +9 -0
- data/node_modules/uri-js/dist/esnext/schemes/wss.js.map +1 -0
- data/node_modules/uri-js/dist/esnext/uri.d.ts +59 -59
- data/node_modules/uri-js/dist/esnext/uri.js +2 -2
- data/node_modules/uri-js/dist/esnext/uri.js.map +1 -1
- data/node_modules/uri-js/dist/esnext/util.d.ts +6 -6
- data/node_modules/uri-js/dist/esnext/util.js +35 -35
- data/node_modules/uri-js/dist/esnext/util.js.map +0 -0
- data/node_modules/uri-js/package.json +19 -7
- data/node_modules/uri-js/yarn.lock +1271 -615
- data/trusty_cms.gemspec +2 -1
- data/yarn.lock +9 -9
- metadata +9 -21
- data/node_modules/uri-js/bower.json +0 -47
- data/node_modules/uri-js/rollup.config.js +0 -32
- data/node_modules/uri-js/src/index.ts +0 -18
- data/node_modules/uri-js/src/punycode.d.ts +0 -24
- data/node_modules/uri-js/src/regexps-iri.ts +0 -4
- data/node_modules/uri-js/src/regexps-uri.ts +0 -89
- data/node_modules/uri-js/src/schemes/http.ts +0 -36
- data/node_modules/uri-js/src/schemes/https.ts +0 -11
- data/node_modules/uri-js/src/schemes/mailto.ts +0 -182
- data/node_modules/uri-js/src/schemes/urn-uuid.ts +0 -36
- data/node_modules/uri-js/src/schemes/urn.ts +0 -69
- data/node_modules/uri-js/src/uri.ts +0 -556
- data/node_modules/uri-js/src/util.ts +0 -40
- data/node_modules/uri-js/tests/qunit.css +0 -118
- data/node_modules/uri-js/tests/qunit.js +0 -1042
- data/node_modules/uri-js/tests/test-es5-min.html +0 -17
- data/node_modules/uri-js/tests/test-es5.html +0 -17
- data/node_modules/uri-js/tests/tests.js +0 -774
- data/node_modules/uri-js/tsconfig.json +0 -20
data/node_modules/ajv/README.md
CHANGED
@@ -1,22 +1,91 @@
|
|
1
|
-
<img align="right" alt="Ajv logo" width="160" src="
|
1
|
+
<img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/images/ajv_logo.png">
|
2
2
|
|
3
3
|
# Ajv: Another JSON Schema Validator
|
4
4
|
|
5
5
|
The fastest JSON Schema validator for Node.js and browser. Supports draft-04/06/07.
|
6
6
|
|
7
|
-
[![Build Status](https://travis-ci.org/
|
7
|
+
[![Build Status](https://travis-ci.org/ajv-validator/ajv.svg?branch=master)](https://travis-ci.org/ajv-validator/ajv)
|
8
8
|
[![npm](https://img.shields.io/npm/v/ajv.svg)](https://www.npmjs.com/package/ajv)
|
9
|
+
[![npm (beta)](https://img.shields.io/npm/v/ajv/beta)](https://www.npmjs.com/package/ajv/v/7.0.0-beta.0)
|
9
10
|
[![npm downloads](https://img.shields.io/npm/dm/ajv.svg)](https://www.npmjs.com/package/ajv)
|
10
|
-
[![Coverage Status](https://coveralls.io/repos/
|
11
|
-
[![Greenkeeper badge](https://badges.greenkeeper.io/epoberezkin/ajv.svg)](https://greenkeeper.io/)
|
11
|
+
[![Coverage Status](https://coveralls.io/repos/github/ajv-validator/ajv/badge.svg?branch=master)](https://coveralls.io/github/ajv-validator/ajv?branch=master)
|
12
12
|
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
|
13
|
+
[![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin)
|
14
|
+
|
15
|
+
|
16
|
+
## Ajv v7 beta is released
|
17
|
+
|
18
|
+
[Ajv version 7.0.0-beta.0](https://github.com/ajv-validator/ajv/tree/v7-beta) is released with these changes:
|
19
|
+
|
20
|
+
- to reduce the mistakes in JSON schemas and unexpected validation results, [strict mode](./docs/strict-mode.md) is added - it prohibits ignored or ambiguous JSON Schema elements.
|
21
|
+
- to make code injection from untrusted schemas impossible, [code generation](./docs/codegen.md) is fully re-written to be safe.
|
22
|
+
- to simplify Ajv extensions, the new keyword API that is used by pre-defined keywords is available to user-defined keywords - it is much easier to define any keywords now, especially with subschemas.
|
23
|
+
- schemas are compiled to ES6 code (ES5 code generation is supported with an option).
|
24
|
+
- to improve reliability and maintainability the code is migrated to TypeScript.
|
25
|
+
|
26
|
+
**Please note**:
|
27
|
+
|
28
|
+
- the support for JSON-Schema draft-04 is removed - if you have schemas using "id" attributes you have to replace them with "\$id" (or continue using version 6 that will be supported until 02/28/2021).
|
29
|
+
- all formats are separated to ajv-formats package - they have to be explicitely added if you use them.
|
30
|
+
|
31
|
+
See [release notes](https://github.com/ajv-validator/ajv/releases/tag/v7.0.0-beta.0) for the details.
|
32
|
+
|
33
|
+
To install the new version:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
npm install ajv@beta
|
37
|
+
```
|
38
|
+
|
39
|
+
See [Getting started with v7](https://github.com/ajv-validator/ajv/tree/v7-beta#usage) for code example.
|
40
|
+
|
41
|
+
|
42
|
+
## Mozilla MOSS grant and OpenJS Foundation
|
43
|
+
|
44
|
+
[<img src="https://www.poberezkin.com/images/mozilla.png" width="240" height="68">](https://www.mozilla.org/en-US/moss/) [<img src="https://www.poberezkin.com/images/openjs.png" width="220" height="68">](https://openjsf.org/blog/2020/08/14/ajv-joins-openjs-foundation-as-an-incubation-project/)
|
45
|
+
|
46
|
+
Ajv has been awarded a grant from Mozilla’s [Open Source Support (MOSS) program](https://www.mozilla.org/en-US/moss/) in the “Foundational Technology” track! It will sponsor the development of Ajv support of [JSON Schema version 2019-09](https://tools.ietf.org/html/draft-handrews-json-schema-02) and of [JSON Type Definition](https://tools.ietf.org/html/draft-ucarion-json-type-definition-04).
|
47
|
+
|
48
|
+
Ajv also joined [OpenJS Foundation](https://openjsf.org/) – having this support will help ensure the longevity and stability of Ajv for all its users.
|
49
|
+
|
50
|
+
This [blog post](https://www.poberezkin.com/posts/2020-08-14-ajv-json-validator-mozilla-open-source-grant-openjs-foundation.html) has more details.
|
51
|
+
|
52
|
+
I am looking for the long term maintainers of Ajv – working with [ReadySet](https://www.thereadyset.co/), also sponsored by Mozilla, to establish clear guidelines for the role of a "maintainer" and the contribution standards, and to encourage a wider, more inclusive, contribution from the community.
|
53
|
+
|
54
|
+
|
55
|
+
## Please [sponsor Ajv development](https://github.com/sponsors/epoberezkin)
|
56
|
+
|
57
|
+
Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant!
|
58
|
+
|
59
|
+
Your continuing support is very important - the funds will be used to develop and maintain Ajv once the next major version is released.
|
60
|
+
|
61
|
+
Please sponsor Ajv via:
|
62
|
+
- [GitHub sponsors page](https://github.com/sponsors/epoberezkin) (GitHub will match it)
|
63
|
+
- [Ajv Open Collective️](https://opencollective.com/ajv)
|
64
|
+
|
65
|
+
Thank you.
|
66
|
+
|
67
|
+
|
68
|
+
#### Open Collective sponsors
|
69
|
+
|
70
|
+
<a href="https://opencollective.com/ajv"><img src="https://opencollective.com/ajv/individuals.svg?width=890"></a>
|
71
|
+
|
72
|
+
<a href="https://opencollective.com/ajv/organization/0/website"><img src="https://opencollective.com/ajv/organization/0/avatar.svg"></a>
|
73
|
+
<a href="https://opencollective.com/ajv/organization/1/website"><img src="https://opencollective.com/ajv/organization/1/avatar.svg"></a>
|
74
|
+
<a href="https://opencollective.com/ajv/organization/2/website"><img src="https://opencollective.com/ajv/organization/2/avatar.svg"></a>
|
75
|
+
<a href="https://opencollective.com/ajv/organization/3/website"><img src="https://opencollective.com/ajv/organization/3/avatar.svg"></a>
|
76
|
+
<a href="https://opencollective.com/ajv/organization/4/website"><img src="https://opencollective.com/ajv/organization/4/avatar.svg"></a>
|
77
|
+
<a href="https://opencollective.com/ajv/organization/5/website"><img src="https://opencollective.com/ajv/organization/5/avatar.svg"></a>
|
78
|
+
<a href="https://opencollective.com/ajv/organization/6/website"><img src="https://opencollective.com/ajv/organization/6/avatar.svg"></a>
|
79
|
+
<a href="https://opencollective.com/ajv/organization/7/website"><img src="https://opencollective.com/ajv/organization/7/avatar.svg"></a>
|
80
|
+
<a href="https://opencollective.com/ajv/organization/8/website"><img src="https://opencollective.com/ajv/organization/8/avatar.svg"></a>
|
81
|
+
<a href="https://opencollective.com/ajv/organization/9/website"><img src="https://opencollective.com/ajv/organization/9/avatar.svg"></a>
|
13
82
|
|
14
83
|
|
15
84
|
## Using version 6
|
16
85
|
|
17
86
|
[JSON Schema draft-07](http://json-schema.org/latest/json-schema-validation.html) is published.
|
18
87
|
|
19
|
-
[Ajv version 6.0.0](https://github.com/
|
88
|
+
[Ajv version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0) that supports draft-07 is released. It may require either migrating your schemas or updating your code (to continue using draft-04 and v5 schemas, draft-06 schemas will be supported without changes).
|
20
89
|
|
21
90
|
__Please note__: To use Ajv with draft-06 schemas you need to explicitly add the meta-schema to the validator instance:
|
22
91
|
|
@@ -39,8 +108,9 @@ ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
|
|
39
108
|
- [Performance](#performance)
|
40
109
|
- [Features](#features)
|
41
110
|
- [Getting started](#getting-started)
|
42
|
-
- [Frequently Asked Questions](https://github.com/
|
111
|
+
- [Frequently Asked Questions](https://github.com/ajv-validator/ajv/blob/master/FAQ.md)
|
43
112
|
- [Using in browser](#using-in-browser)
|
113
|
+
- [Ajv and Content Security Policies (CSP)](#ajv-and-content-security-policies-csp)
|
44
114
|
- [Command line interface](#command-line-interface)
|
45
115
|
- Validation
|
46
116
|
- [Keywords](#validation-keywords)
|
@@ -69,7 +139,8 @@ ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
|
|
69
139
|
- [Plugins](#plugins)
|
70
140
|
- [Related packages](#related-packages)
|
71
141
|
- [Some packages using Ajv](#some-packages-using-ajv)
|
72
|
-
- [Tests, Contributing,
|
142
|
+
- [Tests, Contributing, Changes history](#tests)
|
143
|
+
- [Support, Code of conduct, License](#open-source-software-support)
|
73
144
|
|
74
145
|
|
75
146
|
## Performance
|
@@ -92,29 +163,27 @@ Performance of different validators by [json-schema-benchmark](https://github.co
|
|
92
163
|
## Features
|
93
164
|
|
94
165
|
- Ajv implements full JSON Schema [draft-06/07](http://json-schema.org/) and draft-04 standards:
|
95
|
-
- all validation keywords (see [JSON Schema validation keywords](https://github.com/
|
166
|
+
- all validation keywords (see [JSON Schema validation keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md))
|
96
167
|
- full support of remote refs (remote schemas have to be added with `addSchema` or compiled to be available)
|
97
168
|
- support of circular references between schemas
|
98
169
|
- correct string lengths for strings with unicode pairs (can be turned off)
|
99
170
|
- [formats](#formats) defined by JSON Schema draft-07 standard and custom formats (can be turned off)
|
100
171
|
- [validates schemas against meta-schema](#api-validateschema)
|
101
|
-
- supports [browsers](#using-in-browser) and Node.js 0.10-
|
172
|
+
- supports [browsers](#using-in-browser) and Node.js 0.10-14.x
|
102
173
|
- [asynchronous loading](#asynchronous-schema-compilation) of referenced schemas during compilation
|
103
174
|
- "All errors" validation mode with [option allErrors](#options)
|
104
175
|
- [error messages with parameters](#validation-errors) describing error reasons to allow creating custom error messages
|
105
|
-
- i18n error messages support with [ajv-i18n](https://github.com/
|
176
|
+
- i18n error messages support with [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package
|
106
177
|
- [filtering data](#filtering-data) from additional properties
|
107
178
|
- [assigning defaults](#assigning-defaults) to missing properties and items
|
108
179
|
- [coercing data](#coercing-data-types) to the types specified in `type` keywords
|
109
180
|
- [custom keywords](#defining-custom-keywords)
|
110
181
|
- draft-06/07 keywords `const`, `contains`, `propertyNames` and `if/then/else`
|
111
182
|
- draft-06 boolean schemas (`true`/`false` as a schema to always pass/fail).
|
112
|
-
- keywords `switch`, `patternRequired`, `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum` from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) with [ajv-keywords](https://github.com/
|
183
|
+
- keywords `switch`, `patternRequired`, `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum` from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) with [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package
|
113
184
|
- [$data reference](#data-reference) to use values from the validated data as values for the schema keywords
|
114
185
|
- [asynchronous validation](#asynchronous-validation) of custom formats and keywords
|
115
186
|
|
116
|
-
Currently Ajv is the only validator that passes all the tests from [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) (according to [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark), apart from the test that requires that `1.0` is not an integer that is impossible to satisfy in JavaScript).
|
117
|
-
|
118
187
|
|
119
188
|
## Install
|
120
189
|
|
@@ -193,21 +262,31 @@ Ajv is tested with these browsers:
|
|
193
262
|
|
194
263
|
[![Sauce Test Status](https://saucelabs.com/browser-matrix/epoberezkin.svg)](https://saucelabs.com/u/epoberezkin)
|
195
264
|
|
196
|
-
__Please note__: some frameworks, e.g. Dojo, may redefine global require in such way that is not compatible with CommonJS module format. In such case Ajv bundle has to be loaded before the framework and then you can use global Ajv (see issue [#234](https://github.com/
|
265
|
+
__Please note__: some frameworks, e.g. Dojo, may redefine global require in such way that is not compatible with CommonJS module format. In such case Ajv bundle has to be loaded before the framework and then you can use global Ajv (see issue [#234](https://github.com/ajv-validator/ajv/issues/234)).
|
266
|
+
|
267
|
+
|
268
|
+
### Ajv and Content Security Policies (CSP)
|
269
|
+
|
270
|
+
If you're using Ajv to compile a schema (the typical use) in a browser document that is loaded with a Content Security Policy (CSP), that policy will require a `script-src` directive that includes the value `'unsafe-eval'`.
|
271
|
+
:warning: NOTE, however, that `unsafe-eval` is NOT recommended in a secure CSP[[1]](https://developer.chrome.com/extensions/contentSecurityPolicy#relaxing-eval), as it has the potential to open the document to cross-site scripting (XSS) attacks.
|
272
|
+
|
273
|
+
In order to make use of Ajv without easing your CSP, you can [pre-compile a schema using the CLI](https://github.com/ajv-validator/ajv-cli#compile-schemas). This will transpile the schema JSON into a JavaScript file that exports a `validate` function that works simlarly to a schema compiled at runtime.
|
274
|
+
|
275
|
+
Note that pre-compilation of schemas is performed using [ajv-pack](https://github.com/ajv-validator/ajv-pack) and there are [some limitations to the schema features it can compile](https://github.com/ajv-validator/ajv-pack#limitations). A successfully pre-compiled schema is equivalent to the same schema compiled at runtime.
|
197
276
|
|
198
277
|
|
199
278
|
## Command line interface
|
200
279
|
|
201
|
-
CLI is available as a separate npm package [ajv-cli](https://github.com/
|
280
|
+
CLI is available as a separate npm package [ajv-cli](https://github.com/ajv-validator/ajv-cli). It supports:
|
202
281
|
|
203
282
|
- compiling JSON Schemas to test their validity
|
204
|
-
- BETA: generating standalone module exporting a validation function to be used without Ajv (using [ajv-pack](https://github.com/
|
283
|
+
- BETA: generating standalone module exporting a validation function to be used without Ajv (using [ajv-pack](https://github.com/ajv-validator/ajv-pack))
|
205
284
|
- migrate schemas to draft-07 (using [json-schema-migrate](https://github.com/epoberezkin/json-schema-migrate))
|
206
285
|
- validating data file(s) against JSON Schema
|
207
286
|
- testing expected validity of data against JSON Schema
|
208
287
|
- referenced schemas
|
209
288
|
- custom meta-schemas
|
210
|
-
- files in JSON and JavaScript format
|
289
|
+
- files in JSON, JSON5, YAML, and JavaScript format
|
211
290
|
- all Ajv options
|
212
291
|
- reporting changes in data after validation in [JSON-patch](https://tools.ietf.org/html/rfc6902) format
|
213
292
|
|
@@ -216,20 +295,20 @@ CLI is available as a separate npm package [ajv-cli](https://github.com/jessedc/
|
|
216
295
|
|
217
296
|
Ajv supports all validation keywords from draft-07 of JSON Schema standard:
|
218
297
|
|
219
|
-
- [type](https://github.com/
|
220
|
-
- [for numbers](https://github.com/
|
221
|
-
- [for strings](https://github.com/
|
222
|
-
- [for arrays](https://github.com/
|
223
|
-
- [for objects](https://github.com/
|
224
|
-
- [for all types](https://github.com/
|
225
|
-
- [compound keywords](https://github.com/
|
298
|
+
- [type](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#type)
|
299
|
+
- [for numbers](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-numbers) - maximum, minimum, exclusiveMaximum, exclusiveMinimum, multipleOf
|
300
|
+
- [for strings](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-strings) - maxLength, minLength, pattern, format
|
301
|
+
- [for arrays](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-arrays) - maxItems, minItems, uniqueItems, items, additionalItems, [contains](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#contains)
|
302
|
+
- [for objects](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-objects) - maxProperties, minProperties, required, properties, patternProperties, additionalProperties, dependencies, [propertyNames](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#propertynames)
|
303
|
+
- [for all types](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-all-types) - enum, [const](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#const)
|
304
|
+
- [compound keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#compound-keywords) - not, oneOf, anyOf, allOf, [if/then/else](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#ifthenelse)
|
226
305
|
|
227
|
-
With [ajv-keywords](https://github.com/
|
306
|
+
With [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package Ajv also supports validation keywords from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) for JSON Schema standard:
|
228
307
|
|
229
|
-
- [patternRequired](https://github.com/
|
230
|
-
- [formatMaximum, formatMinimum, formatExclusiveMaximum, formatExclusiveMinimum](https://github.com/
|
308
|
+
- [patternRequired](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#patternrequired-proposed) - like `required` but with patterns that some property should match.
|
309
|
+
- [formatMaximum, formatMinimum, formatExclusiveMaximum, formatExclusiveMinimum](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#formatmaximum--formatminimum-and-exclusiveformatmaximum--exclusiveformatminimum-proposed) - setting limits for date, time, etc.
|
231
310
|
|
232
|
-
See [JSON Schema validation keywords](https://github.com/
|
311
|
+
See [JSON Schema validation keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md) for more details.
|
233
312
|
|
234
313
|
|
235
314
|
## Annotation keywords
|
@@ -273,13 +352,13 @@ The following formats are implemented for string validation with "format" keywor
|
|
273
352
|
|
274
353
|
__Please note__: JSON Schema draft-07 also defines formats `iri`, `iri-reference`, `idn-hostname` and `idn-email` for URLs, hostnames and emails with international characters. Ajv does not implement these formats. If you create Ajv plugin that implements them please make a PR to mention this plugin here.
|
275
354
|
|
276
|
-
There are two modes of format validation: `fast` and `full`. This mode affects formats `date`, `time`, `date-time`, `uri`, `uri-reference`,
|
355
|
+
There are two modes of format validation: `fast` and `full`. This mode affects formats `date`, `time`, `date-time`, `uri`, `uri-reference`, and `email`. See [Options](#options) for details.
|
277
356
|
|
278
357
|
You can add additional formats and replace any of the formats above using [addFormat](#api-addformat) method.
|
279
358
|
|
280
|
-
The option `unknownFormats` allows changing the default behaviour when an unknown format is encountered. In this case Ajv can either fail schema compilation (default) or ignore it (default in versions before 5.0.0). You also can
|
359
|
+
The option `unknownFormats` allows changing the default behaviour when an unknown format is encountered. In this case Ajv can either fail schema compilation (default) or ignore it (default in versions before 5.0.0). You also can allow specific format(s) that will be ignored. See [Options](#options) for details.
|
281
360
|
|
282
|
-
You can find regular expressions used for format validation and the sources that were used in [formats.js](https://github.com/
|
361
|
+
You can find regular expressions used for format validation and the sources that were used in [formats.js](https://github.com/ajv-validator/ajv/blob/master/lib/compile/formats.js).
|
283
362
|
|
284
363
|
|
285
364
|
## <a name="ref"></a>Combining schemas with $ref
|
@@ -388,7 +467,7 @@ var validData = {
|
|
388
467
|
|
389
468
|
## $merge and $patch keywords
|
390
469
|
|
391
|
-
With the package [ajv-merge-patch](https://github.com/
|
470
|
+
With the package [ajv-merge-patch](https://github.com/ajv-validator/ajv-merge-patch) you can use the keywords `$merge` and `$patch` that allow extending JSON Schemas with patches using formats [JSON Merge Patch (RFC 7396)](https://tools.ietf.org/html/rfc7396) and [JSON Patch (RFC 6902)](https://tools.ietf.org/html/rfc6902).
|
392
471
|
|
393
472
|
To add keywords `$merge` and `$patch` to Ajv instance use this code:
|
394
473
|
|
@@ -447,7 +526,7 @@ The schemas above are equivalent to this schema:
|
|
447
526
|
|
448
527
|
The properties `source` and `with` in the keywords `$merge` and `$patch` can use absolute or relative `$ref` to point to other schemas previously added to the Ajv instance or to the fragments of the current schema.
|
449
528
|
|
450
|
-
See the package [ajv-merge-patch](https://github.com/
|
529
|
+
See the package [ajv-merge-patch](https://github.com/ajv-validator/ajv-merge-patch) for more information.
|
451
530
|
|
452
531
|
|
453
532
|
## Defining custom keywords
|
@@ -495,9 +574,9 @@ console.log(validate(2)); // false
|
|
495
574
|
console.log(validate(4)); // false
|
496
575
|
```
|
497
576
|
|
498
|
-
Several custom keywords (typeof, instanceof, range and propertyNames) are defined in [ajv-keywords](https://github.com/
|
577
|
+
Several custom keywords (typeof, instanceof, range and propertyNames) are defined in [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package - they can be used for your schemas and as a starting point for your own custom keywords.
|
499
578
|
|
500
|
-
See [Defining custom keywords](https://github.com/
|
579
|
+
See [Defining custom keywords](https://github.com/ajv-validator/ajv/blob/master/CUSTOM.md) for more details.
|
501
580
|
|
502
581
|
|
503
582
|
## Asynchronous schema compilation
|
@@ -596,7 +675,7 @@ validate({ userId: 1, postId: 19 })
|
|
596
675
|
|
597
676
|
### Using transpilers with asynchronous validation functions.
|
598
677
|
|
599
|
-
[ajv-async](https://github.com/
|
678
|
+
[ajv-async](https://github.com/ajv-validator/ajv-async) uses [nodent](https://github.com/MatAtBread/nodent) to transpile async functions. To use another transpiler you should separately install it (or load its bundle in the browser).
|
600
679
|
|
601
680
|
|
602
681
|
#### Using nodent
|
@@ -640,7 +719,7 @@ Ajv treats JSON schemas as trusted as your application code. This security model
|
|
640
719
|
|
641
720
|
If your schemas are received from untrusted sources (or generated from untrusted data) there are several scenarios you need to prevent:
|
642
721
|
- compiling schemas can cause stack overflow (if they are too deep)
|
643
|
-
- compiling schemas can be slow (e.g. [#557](https://github.com/
|
722
|
+
- compiling schemas can be slow (e.g. [#557](https://github.com/ajv-validator/ajv/issues/557))
|
644
723
|
- validating certain data can be slow
|
645
724
|
|
646
725
|
It is difficult to predict all the scenarios, but at the very least it may help to limit the size of untrusted schemas (e.g. limit JSON string length) and also the maximum schema object depth (that can be high for relatively small JSON strings). You also may want to mitigate slow regular expressions in `pattern` and `patternProperties` keywords.
|
@@ -650,7 +729,7 @@ Regardless the measures you take, using untrusted schemas increases security ris
|
|
650
729
|
|
651
730
|
##### Circular references in JavaScript objects
|
652
731
|
|
653
|
-
Ajv does not support schemas and validated data that have circular references in objects. See [issue #802](https://github.com/
|
732
|
+
Ajv does not support schemas and validated data that have circular references in objects. See [issue #802](https://github.com/ajv-validator/ajv/issues/802).
|
654
733
|
|
655
734
|
An attempt to compile such schemas or validate such data would cause stack overflow (or will not complete in case of asynchronous validation). Depending on the parser you use, untrusted data can lead to circular references.
|
656
735
|
|
@@ -665,7 +744,7 @@ Some keywords in JSON Schemas can lead to very slow validation for certain data.
|
|
665
744
|
|
666
745
|
__Please note__: The suggestions above to prevent slow validation would only work if you do NOT use `allErrors: true` in production code (using it would continue validation after validation errors).
|
667
746
|
|
668
|
-
You can validate your JSON schemas against [this meta-schema](https://github.com/
|
747
|
+
You can validate your JSON schemas against [this meta-schema](https://github.com/ajv-validator/ajv/blob/master/lib/refs/json-schema-secure.json) to check that these recommendations are followed:
|
669
748
|
|
670
749
|
```javascript
|
671
750
|
const isSchemaSecure = ajv.compile(require('ajv/lib/refs/json-schema-secure.json'));
|
@@ -680,13 +759,17 @@ isSchemaSecure(schema2); // true
|
|
680
759
|
__Please note__: following all these recommendation is not a guarantee that validation of untrusted data is safe - it can still lead to some undesirable results.
|
681
760
|
|
682
761
|
|
762
|
+
##### Content Security Policies (CSP)
|
763
|
+
See [Ajv and Content Security Policies (CSP)](#ajv-and-content-security-policies-csp)
|
764
|
+
|
765
|
+
|
683
766
|
## ReDoS attack
|
684
767
|
|
685
768
|
Certain regular expressions can lead to the exponential evaluation time even with relatively short strings.
|
686
769
|
|
687
770
|
Please assess the regular expressions you use in the schemas on their vulnerability to this attack - see [safe-regex](https://github.com/substack/safe-regex), for example.
|
688
771
|
|
689
|
-
__Please note__: some formats that Ajv implements use [regular expressions](https://github.com/
|
772
|
+
__Please note__: some formats that Ajv implements use [regular expressions](https://github.com/ajv-validator/ajv/blob/master/lib/compile/formats.js) that can be vulnerable to ReDoS attack, so if you use Ajv to validate data from untrusted sources __it is strongly recommended__ to consider the following:
|
690
773
|
|
691
774
|
- making assessment of "format" implementations in Ajv.
|
692
775
|
- using `format: 'fast'` option that simplifies some of the regular expressions (although it does not guarantee that they are safe).
|
@@ -766,7 +849,7 @@ The intention of the schema above is to allow objects with either the string pro
|
|
766
849
|
|
767
850
|
With the option `removeAdditional: true` the validation will pass for the object `{ "foo": "abc"}` but will fail for the object `{"bar": 1}`. It happens because while the first subschema in `oneOf` is validated, the property `bar` is removed because it is an additional property according to the standard (because it is not included in `properties` keyword in the same schema).
|
768
851
|
|
769
|
-
While this behaviour is unexpected (issues [#129](https://github.com/
|
852
|
+
While this behaviour is unexpected (issues [#129](https://github.com/ajv-validator/ajv/issues/129), [#134](https://github.com/ajv-validator/ajv/issues/134)), it is correct. To have the expected behaviour (both objects are allowed and additional properties are removed) the schema has to be refactored in this way:
|
770
853
|
|
771
854
|
```json
|
772
855
|
{
|
@@ -840,7 +923,7 @@ console.log(data); // [ 1, "foo" ]
|
|
840
923
|
`default` keywords in other cases are ignored:
|
841
924
|
|
842
925
|
- not in `properties` or `items` subschemas
|
843
|
-
- in schemas inside `anyOf`, `oneOf` and `not` (see [#42](https://github.com/
|
926
|
+
- in schemas inside `anyOf`, `oneOf` and `not` (see [#42](https://github.com/ajv-validator/ajv/issues/42))
|
844
927
|
- in `if` subschema of `switch` keyword
|
845
928
|
- in schemas generated by custom macro keywords
|
846
929
|
|
@@ -898,7 +981,7 @@ console.log(data); // { "foo": [1], "bar": false }
|
|
898
981
|
|
899
982
|
The coercion rules, as you can see from the example, are different from JavaScript both to validate user input as expected and to have the coercion reversible (to correctly validate cases where different types are defined in subschemas of "anyOf" and other compound keywords).
|
900
983
|
|
901
|
-
See [Coercion rules](https://github.com/
|
984
|
+
See [Coercion rules](https://github.com/ajv-validator/ajv/blob/master/COERCION.md) for details.
|
902
985
|
|
903
986
|
|
904
987
|
## API
|
@@ -1016,9 +1099,9 @@ Function should return validation result as `true` or `false`.
|
|
1016
1099
|
If object is passed it should have properties `validate`, `compare` and `async`:
|
1017
1100
|
|
1018
1101
|
- _validate_: a string, RegExp or a function as described above.
|
1019
|
-
- _compare_: an optional comparison function that accepts two strings and compares them according to the format meaning. This function is used with keywords `formatMaximum`/`formatMinimum` (defined in [ajv-keywords](https://github.com/
|
1102
|
+
- _compare_: an optional comparison function that accepts two strings and compares them according to the format meaning. This function is used with keywords `formatMaximum`/`formatMinimum` (defined in [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package). It should return `1` if the first value is bigger than the second value, `-1` if it is smaller and `0` if it is equal.
|
1020
1103
|
- _async_: an optional `true` value if `validate` is an asynchronous function; in this case it should return a promise that resolves with a value `true` or `false`.
|
1021
|
-
- _type_: an optional type of data that the format applies to. It can be `"string"` (default) or `"number"` (see https://github.com/
|
1104
|
+
- _type_: an optional type of data that the format applies to. It can be `"string"` (default) or `"number"` (see https://github.com/ajv-validator/ajv/issues/291#issuecomment-259923858). If the type of data is different, the validation will pass.
|
1022
1105
|
|
1023
1106
|
Custom formats can be also added via `formats` option.
|
1024
1107
|
|
@@ -1114,6 +1197,7 @@ Defaults:
|
|
1114
1197
|
// strict mode options
|
1115
1198
|
strictDefaults: false,
|
1116
1199
|
strictKeywords: false,
|
1200
|
+
strictNumbers: false,
|
1117
1201
|
// asynchronous validation options:
|
1118
1202
|
transpile: undefined, // requires ajv-async package
|
1119
1203
|
// advanced options:
|
@@ -1128,7 +1212,7 @@ Defaults:
|
|
1128
1212
|
errorDataPath: 'object', // deprecated
|
1129
1213
|
messages: true,
|
1130
1214
|
sourceCode: false,
|
1131
|
-
processCode: undefined, // function (str: string): string {}
|
1215
|
+
processCode: undefined, // function (str: string, schema: object): string {}
|
1132
1216
|
cache: new Cache,
|
1133
1217
|
serialize: undefined
|
1134
1218
|
}
|
@@ -1192,7 +1276,7 @@ Defaults:
|
|
1192
1276
|
- `true` - insert defaults by value (object literal is used).
|
1193
1277
|
- `"empty"` - in addition to missing or undefined, use defaults for properties and items that are equal to `null` or `""` (an empty string).
|
1194
1278
|
- `"shared"` (deprecated) - insert defaults by reference. If the default is an object, it will be shared by all instances of validated data. If you modify the inserted default in the validated data, it will be modified in the schema as well.
|
1195
|
-
- _coerceTypes_: change data type of data to match `type` keyword. See the example in [Coercing data types](#coercing-data-types) and [coercion rules](https://github.com/
|
1279
|
+
- _coerceTypes_: change data type of data to match `type` keyword. See the example in [Coercing data types](#coercing-data-types) and [coercion rules](https://github.com/ajv-validator/ajv/blob/master/COERCION.md). Option values:
|
1196
1280
|
- `false` (default) - no type coercion.
|
1197
1281
|
- `true` - coerce scalar data types.
|
1198
1282
|
- `"array"` - in addition to coercions between scalar types, coerce scalar data to an array with one element and vice versa (as required by the schema).
|
@@ -1208,11 +1292,13 @@ Defaults:
|
|
1208
1292
|
- `false` (default) - unknown keywords are not reported
|
1209
1293
|
- `true` - if an unknown keyword is present, throw an error
|
1210
1294
|
- `"log"` - if an unknown keyword is present, log warning
|
1211
|
-
|
1295
|
+
- _strictNumbers_: validate numbers strictly, failing validation for NaN and Infinity. Option values:
|
1296
|
+
- `false` (default) - NaN or Infinity will pass validation for numeric types
|
1297
|
+
- `true` - NaN or Infinity will not pass validation for numeric types
|
1212
1298
|
|
1213
1299
|
##### Asynchronous validation options
|
1214
1300
|
|
1215
|
-
- _transpile_: Requires [ajv-async](https://github.com/
|
1301
|
+
- _transpile_: Requires [ajv-async](https://github.com/ajv-validator/ajv-async) package. It determines whether Ajv transpiles compiled asynchronous validation function. Option values:
|
1216
1302
|
- `undefined` (default) - transpile with [nodent](https://github.com/MatAtBread/nodent) if async functions are not supported.
|
1217
1303
|
- `true` - always transpile with nodent.
|
1218
1304
|
- `false` - do not transpile; if async functions are not supported an exception will be thrown.
|
@@ -1233,13 +1319,13 @@ Defaults:
|
|
1233
1319
|
- _passContext_: pass validation context to custom keyword functions. If this option is `true` and you pass some context to the compiled validation function with `validate.call(context, data)`, the `context` will be available as `this` in your custom keywords. By default `this` is Ajv instance.
|
1234
1320
|
- _loopRequired_: by default `required` keyword is compiled into a single expression (or a sequence of statements in `allErrors` mode). In case of a very large number of properties in this keyword it may result in a very big validation function. Pass integer to set the number of properties above which `required` keyword will be validated in a loop - smaller validation function size but also worse performance.
|
1235
1321
|
- _ownProperties_: by default Ajv iterates over all enumerable object properties; when this option is `true` only own enumerable object properties (i.e. found directly on the object rather than on its prototype) are iterated. Contributed by @mbroadst.
|
1236
|
-
- _multipleOfPrecision_: by default `multipleOf` keyword is validated by comparing the result of division with parseInt() of that result. It works for dividers that are bigger than 1. For small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer, see issue [#84](https://github.com/
|
1322
|
+
- _multipleOfPrecision_: by default `multipleOf` keyword is validated by comparing the result of division with parseInt() of that result. It works for dividers that are bigger than 1. For small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer, see issue [#84](https://github.com/ajv-validator/ajv/issues/84)). If you need to use fractional dividers set this option to some positive integer N to have `multipleOf` validated using this formula: `Math.abs(Math.round(division) - division) < 1e-N` (it is slower but allows for float arithmetics deviations).
|
1237
1323
|
- _errorDataPath_ (deprecated): set `dataPath` to point to 'object' (default) or to 'property' when validating keywords `required`, `additionalProperties` and `dependencies`.
|
1238
|
-
- _messages_: Include human-readable messages in errors. `true` by default. `false` can be passed when custom messages are used (e.g. with [ajv-i18n](https://github.com/
|
1324
|
+
- _messages_: Include human-readable messages in errors. `true` by default. `false` can be passed when custom messages are used (e.g. with [ajv-i18n](https://github.com/ajv-validator/ajv-i18n)).
|
1239
1325
|
- _sourceCode_: add `sourceCode` property to validating function (for debugging; this code can be different from the result of toString call).
|
1240
1326
|
- _processCode_: an optional function to process generated code before it is passed to Function constructor. It can be used to either beautify (the validating function is generated without line-breaks) or to transpile code. Starting from version 5.0.0 this option replaced options:
|
1241
|
-
- `beautify` that formatted the generated function using [js-beautify](https://github.com/beautify-web/js-beautify). If you want to beautify the generated code pass `require('js-beautify').js_beautify`.
|
1242
|
-
- `transpile` that transpiled asynchronous validation function. You can still use `transpile` option with [ajv-async](https://github.com/
|
1327
|
+
- `beautify` that formatted the generated function using [js-beautify](https://github.com/beautify-web/js-beautify). If you want to beautify the generated code pass a function calling `require('js-beautify').js_beautify` as `processCode: code => js_beautify(code)`.
|
1328
|
+
- `transpile` that transpiled asynchronous validation function. You can still use `transpile` option with [ajv-async](https://github.com/ajv-validator/ajv-async) package. See [Asynchronous validation](#asynchronous-validation) for more information.
|
1243
1329
|
- _cache_: an optional instance of cache to store compiled schemas using stable-stringified schema as a key. For example, set-associative cache [sacjs](https://github.com/epoberezkin/sacjs) can be used. If not passed then a simple hash is used which is good enough for the common use case (a limited number of statically defined schemas). Cache should have methods `put(key, value)`, `get(key)`, `del(key)` and `clear()`.
|
1244
1330
|
- _serialize_: an optional function to serialize schema to cache key. Pass `false` to use schema itself as a key (e.g., if WeakMap used as a cache). By default [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used.
|
1245
1331
|
|
@@ -1256,7 +1342,7 @@ Each error is an object with the following properties:
|
|
1256
1342
|
- _keyword_: validation keyword.
|
1257
1343
|
- _dataPath_: the path to the part of the data that was validated. By default `dataPath` uses JavaScript property access notation (e.g., `".prop[1].subProp"`). When the option `jsonPointers` is true (see [Options](#options)) `dataPath` will be set using JSON pointer standard (e.g., `"/prop/1/subProp"`).
|
1258
1344
|
- _schemaPath_: the path (JSON-pointer as a URI fragment) to the schema of the keyword that failed validation.
|
1259
|
-
- _params_: the object with the additional information about error that can be used to create custom error messages (e.g., using [ajv-i18n](https://github.com/
|
1345
|
+
- _params_: the object with the additional information about error that can be used to create custom error messages (e.g., using [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package). See below for parameters set by all keywords.
|
1260
1346
|
- _message_: the standard error message (can be excluded with option `messages` set to false).
|
1261
1347
|
- _schema_: the schema of the keyword (added with `verbose` option).
|
1262
1348
|
- _parentSchema_: the schema containing the keyword (added with `verbose` option)
|
@@ -1331,16 +1417,16 @@ If you have published a useful plugin please submit a PR to add it to the next s
|
|
1331
1417
|
|
1332
1418
|
## Related packages
|
1333
1419
|
|
1334
|
-
- [ajv-async](https://github.com/
|
1420
|
+
- [ajv-async](https://github.com/ajv-validator/ajv-async) - plugin to configure async validation mode
|
1335
1421
|
- [ajv-bsontype](https://github.com/BoLaMN/ajv-bsontype) - plugin to validate mongodb's bsonType formats
|
1336
1422
|
- [ajv-cli](https://github.com/jessedc/ajv-cli) - command line interface
|
1337
|
-
- [ajv-errors](https://github.com/
|
1338
|
-
- [ajv-i18n](https://github.com/
|
1339
|
-
- [ajv-istanbul](https://github.com/
|
1340
|
-
- [ajv-keywords](https://github.com/
|
1341
|
-
- [ajv-merge-patch](https://github.com/
|
1342
|
-
- [ajv-pack](https://github.com/
|
1343
|
-
|
1423
|
+
- [ajv-errors](https://github.com/ajv-validator/ajv-errors) - plugin for custom error messages
|
1424
|
+
- [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) - internationalised error messages
|
1425
|
+
- [ajv-istanbul](https://github.com/ajv-validator/ajv-istanbul) - plugin to instrument generated validation code to measure test coverage of your schemas
|
1426
|
+
- [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) - plugin with custom validation keywords (select, typeof, etc.)
|
1427
|
+
- [ajv-merge-patch](https://github.com/ajv-validator/ajv-merge-patch) - plugin with keywords $merge and $patch
|
1428
|
+
- [ajv-pack](https://github.com/ajv-validator/ajv-pack) - produces a compact module exporting validation functions
|
1429
|
+
- [ajv-formats-draft2019](https://github.com/luzlab/ajv-formats-draft2019) - format validators for draft2019 that aren't already included in ajv (ie. `idn-hostname`, `idn-email`, `iri`, `iri-reference` and `duration`).
|
1344
1430
|
|
1345
1431
|
## Some packages using Ajv
|
1346
1432
|
|
@@ -1377,28 +1463,28 @@ npm test
|
|
1377
1463
|
|
1378
1464
|
## Contributing
|
1379
1465
|
|
1380
|
-
All validation functions are generated using doT templates in [dot](https://github.com/
|
1466
|
+
All validation functions are generated using doT templates in [dot](https://github.com/ajv-validator/ajv/tree/master/lib/dot) folder. Templates are precompiled so doT is not a run-time dependency.
|
1381
1467
|
|
1382
|
-
`npm run build` - compiles templates to [dotjs](https://github.com/
|
1468
|
+
`npm run build` - compiles templates to [dotjs](https://github.com/ajv-validator/ajv/tree/master/lib/dotjs) folder.
|
1383
1469
|
|
1384
1470
|
`npm run watch` - automatically compiles templates when files in dot folder change
|
1385
1471
|
|
1386
|
-
Please see [Contributing guidelines](https://github.com/
|
1472
|
+
Please see [Contributing guidelines](https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md)
|
1387
1473
|
|
1388
1474
|
|
1389
1475
|
## Changes history
|
1390
1476
|
|
1391
|
-
See https://github.com/
|
1477
|
+
See https://github.com/ajv-validator/ajv/releases
|
1392
1478
|
|
1393
|
-
__Please note__: [Changes in version
|
1479
|
+
__Please note__: [Changes in version 7.0.0-beta](https://github.com/ajv-validator/ajv/releases/tag/v7.0.0-beta.0)
|
1394
1480
|
|
1395
|
-
[Version
|
1481
|
+
[Version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0).
|
1396
1482
|
|
1397
|
-
|
1483
|
+
## Code of conduct
|
1398
1484
|
|
1399
|
-
[
|
1485
|
+
Please review and follow the [Code of conduct](https://github.com/ajv-validator/ajv/blob/master/CODE_OF_CONDUCT.md).
|
1400
1486
|
|
1401
|
-
|
1487
|
+
Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team.
|
1402
1488
|
|
1403
1489
|
|
1404
1490
|
## Open-source software support
|
@@ -1408,4 +1494,4 @@ Ajv is a part of [Tidelift subscription](https://tidelift.com/subscription/pkg/n
|
|
1408
1494
|
|
1409
1495
|
## License
|
1410
1496
|
|
1411
|
-
[MIT](https://github.com/
|
1497
|
+
[MIT](https://github.com/ajv-validator/ajv/blob/master/LICENSE)
|