Changeset 79a0317 for imaps-frontend/node_modules/ajv
- Timestamp:
- 01/21/25 03:08:24 (3 days ago)
- Branches:
- main
- Parents:
- 0c6b92a
- Location:
- imaps-frontend/node_modules/ajv
- Files:
-
- 459 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/ajv/LICENSE
r0c6b92a r79a0317 1 1 The MIT License (MIT) 2 2 3 Copyright (c) 2015-20 17Evgeny Poberezkin3 Copyright (c) 2015-2021 Evgeny Poberezkin 4 4 5 5 Permission is hereby granted, free of charge, to any person obtaining a copy -
imaps-frontend/node_modules/ajv/README.md
r0c6b92a r79a0317 1 <img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/images/ajv_logo.png"> 2 3 # Ajv: Another JSON Schema Validator 4 5 The fastest JSON Schema validator for Node.js and browser. Supports draft-04/06/07. 6 7 [![Build Status](https://travis-ci.org/ajv-validator/ajv.svg?branch=master)](https://travis-ci.org/ajv-validator/ajv) 1 <img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/img/ajv.svg"> 2 3 4 5 # Ajv JSON schema validator 6 7 The fastest JSON validator for Node.js and browser. 8 9 Supports JSON Schema draft-04/06/07/2019-09/2020-12 ([draft-04 support](https://ajv.js.org/json-schema.html#draft-04) requires ajv-draft-04 package) and JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/). 10 11 [![build](https://github.com/ajv-validator/ajv/actions/workflows/build.yml/badge.svg)](https://github.com/ajv-validator/ajv/actions?query=workflow%3Abuild) 8 12 [![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)10 13 [![npm downloads](https://img.shields.io/npm/dm/ajv.svg)](https://www.npmjs.com/package/ajv) 11 14 [![Coverage Status](https://coveralls.io/repos/github/ajv-validator/ajv/badge.svg?branch=master)](https://coveralls.io/github/ajv-validator/ajv?branch=master) 15 [![SimpleX](https://img.shields.io/badge/chat-on%20SimpleX-70F0F9)](https://simplex.chat/contact#/?v=1-2&smp=smp%3A%2F%2Fu2dS9sG8nMNURyZwqASV4yROM28Er0luVTx5X1CsMrU%3D%40smp4.simplex.im%2F8KvvURM6J38Gdq9dCuPswMOkMny0xCOJ%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAr8rPVRuMOXv6kwF2yUAap-eoVg-9ssOFCi1fIrxTUw0%253D%26srv%3Do5vmywmrnaxalvz6wi3zicyftgio6psuvyniis6gco6bp6ekl4cqj4id.onion&data=%7B%22type%22%3A%22group%22%2C%22groupLinkId%22%3A%224pwLRgWHU9tlroMWHz0uOg%3D%3D%22%7D) 12 16 [![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv) 13 17 [![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin) 14 18 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) 19 ## Ajv sponsors 20 21 [<img src="https://ajv.js.org/img/mozilla.svg" width="45%" alt="Mozilla">](https://www.mozilla.org)<img src="https://ajv.js.org/img/gap.svg" width="9%">[<img src="https://ajv.js.org/img/reserved.svg" width="45%">](https://opencollective.com/ajv) 22 23 [<img src="https://ajv.js.org/img/microsoft.png" width="31%" alt="Microsoft">](https://opensource.microsoft.com)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/reserved.svg" width="31%">](https://opencollective.com/ajv)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/reserved.svg" width="31%">](https://opencollective.com/ajv) 24 25 [<img src="https://ajv.js.org/img/retool.svg" width="22.5%" alt="Retool">](https://retool.com/?utm_source=sponsor&utm_campaign=ajv)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/tidelift.svg" width="22.5%" alt="Tidelift">](https://tidelift.com/subscription/pkg/npm-ajv?utm_source=npm-ajv&utm_medium=referral&utm_campaign=enterprise)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/simplex.svg" width="22.5%" alt="SimpleX">](https://github.com/simplex-chat/simplex-chat)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/reserved.svg" width="22.5%">](https://opencollective.com/ajv) 26 27 ## Contributing 28 29 More than 100 people contributed to Ajv, and we would love to have you join the development. We welcome implementing new features that will benefit many users and ideas to improve our documentation. 30 31 Please review [Contributing guidelines](./CONTRIBUTING.md) and [Code components](https://ajv.js.org/components.html). 32 33 ## Documentation 34 35 All documentation is available on the [Ajv website](https://ajv.js.org). 36 37 Some useful site links: 38 39 - [Getting started](https://ajv.js.org/guide/getting-started.html) 40 - [JSON Schema vs JSON Type Definition](https://ajv.js.org/guide/schema-language.html) 41 - [API reference](https://ajv.js.org/api.html) 42 - [Strict mode](https://ajv.js.org/strict-mode.html) 43 - [Standalone validation code](https://ajv.js.org/standalone.html) 44 - [Security considerations](https://ajv.js.org/security.html) 45 - [Command line interface](https://ajv.js.org/packages/ajv-cli.html) 46 - [Frequently Asked Questions](https://ajv.js.org/faq.html) 47 48 ## <a name="sponsors"></a>Please [sponsor Ajv development](https://github.com/sponsors/epoberezkin) 56 49 57 50 Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant! … … 60 53 61 54 Please sponsor Ajv via: 55 62 56 - [GitHub sponsors page](https://github.com/sponsors/epoberezkin) (GitHub will match it) 63 - [Ajv Open Collective ️](https://opencollective.com/ajv)57 - [Ajv Open Collective](https://opencollective.com/ajv) 64 58 65 59 Thank you. 66 67 60 68 61 #### Open Collective sponsors … … 80 73 <a href="https://opencollective.com/ajv/organization/8/website"><img src="https://opencollective.com/ajv/organization/8/avatar.svg"></a> 81 74 <a href="https://opencollective.com/ajv/organization/9/website"><img src="https://opencollective.com/ajv/organization/9/avatar.svg"></a> 82 83 84 ## Using version 6 85 86 [JSON Schema draft-07](http://json-schema.org/latest/json-schema-validation.html) is published. 87 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). 89 90 __Please note__: To use Ajv with draft-06 schemas you need to explicitly add the meta-schema to the validator instance: 91 92 ```javascript 93 ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')); 94 ``` 95 96 To use Ajv with draft-04 schemas in addition to explicitly adding meta-schema you also need to use option schemaId: 97 98 ```javascript 99 var ajv = new Ajv({schemaId: 'id'}); 100 // If you want to use both draft-04 and draft-06/07 schemas: 101 // var ajv = new Ajv({schemaId: 'auto'}); 102 ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json')); 103 ``` 104 105 106 ## Contents 107 108 - [Performance](#performance) 109 - [Features](#features) 110 - [Getting started](#getting-started) 111 - [Frequently Asked Questions](https://github.com/ajv-validator/ajv/blob/master/FAQ.md) 112 - [Using in browser](#using-in-browser) 113 - [Ajv and Content Security Policies (CSP)](#ajv-and-content-security-policies-csp) 114 - [Command line interface](#command-line-interface) 115 - Validation 116 - [Keywords](#validation-keywords) 117 - [Annotation keywords](#annotation-keywords) 118 - [Formats](#formats) 119 - [Combining schemas with $ref](#ref) 120 - [$data reference](#data-reference) 121 - NEW: [$merge and $patch keywords](#merge-and-patch-keywords) 122 - [Defining custom keywords](#defining-custom-keywords) 123 - [Asynchronous schema compilation](#asynchronous-schema-compilation) 124 - [Asynchronous validation](#asynchronous-validation) 125 - [Security considerations](#security-considerations) 126 - [Security contact](#security-contact) 127 - [Untrusted schemas](#untrusted-schemas) 128 - [Circular references in objects](#circular-references-in-javascript-objects) 129 - [Trusted schemas](#security-risks-of-trusted-schemas) 130 - [ReDoS attack](#redos-attack) 131 - Modifying data during validation 132 - [Filtering data](#filtering-data) 133 - [Assigning defaults](#assigning-defaults) 134 - [Coercing data types](#coercing-data-types) 135 - API 136 - [Methods](#api) 137 - [Options](#options) 138 - [Validation errors](#validation-errors) 139 - [Plugins](#plugins) 140 - [Related packages](#related-packages) 141 - [Some packages using Ajv](#some-packages-using-ajv) 142 - [Tests, Contributing, Changes history](#tests) 143 - [Support, Code of conduct, License](#open-source-software-support) 144 75 <a href="https://opencollective.com/ajv/organization/10/website"><img src="https://opencollective.com/ajv/organization/10/avatar.svg"></a> 76 <a href="https://opencollective.com/ajv/organization/11/website"><img src="https://opencollective.com/ajv/organization/11/avatar.svg"></a> 77 <a href="https://opencollective.com/ajv/organization/12/website"><img src="https://opencollective.com/ajv/organization/12/avatar.svg"></a> 78 <a href="https://opencollective.com/ajv/organization/13/website"><img src="https://opencollective.com/ajv/organization/13/avatar.svg"></a> 79 <a href="https://opencollective.com/ajv/organization/14/website"><img src="https://opencollective.com/ajv/organization/14/avatar.svg"></a> 80 <a href="https://opencollective.com/ajv/organization/15/website"><img src="https://opencollective.com/ajv/organization/15/avatar.svg"></a> 81 <a href="https://opencollective.com/ajv/organization/16/website"><img src="https://opencollective.com/ajv/organization/16/avatar.svg"></a> 82 <a href="https://opencollective.com/ajv/organization/17/website"><img src="https://opencollective.com/ajv/organization/17/avatar.svg"></a> 83 <a href="https://opencollective.com/ajv/organization/18/website"><img src="https://opencollective.com/ajv/organization/18/avatar.svg"></a> 84 <a href="https://opencollective.com/ajv/organization/19/website"><img src="https://opencollective.com/ajv/organization/19/avatar.svg"></a> 85 <a href="https://opencollective.com/ajv/organization/20/website"><img src="https://opencollective.com/ajv/organization/20/avatar.svg"></a> 86 <a href="https://opencollective.com/ajv/organization/21/website"><img src="https://opencollective.com/ajv/organization/21/avatar.svg"></a> 87 <a href="https://opencollective.com/ajv/organization/22/website"><img src="https://opencollective.com/ajv/organization/22/avatar.svg"></a> 88 <a href="https://opencollective.com/ajv/organization/23/website"><img src="https://opencollective.com/ajv/organization/23/avatar.svg"></a> 89 <a href="https://opencollective.com/ajv/organization/24/website"><img src="https://opencollective.com/ajv/organization/24/avatar.svg"></a> 145 90 146 91 ## Performance 147 92 148 Ajv generates code using [doT templates](https://github.com/olado/doT)to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.93 Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization. 149 94 150 95 Currently Ajv is the fastest and the most standard compliant validator according to these benchmarks: … … 155 100 - [themis benchmark](https://cdn.rawgit.com/playlyfe/themis/master/benchmark/results.html) 156 101 157 158 102 Performance of different validators by [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark): 159 103 160 [![performance](https://chart.googleapis.com/chart?chxt=x,y&cht=bhs&chco=76A4FB&chls=2.0&chbh=32,4,1&chs=600x416&chxl=-1:|djv|ajv|json-schema-validator-generator|jsen|is-my-json-valid|themis|z-schema|jsck|skeemas|json-schema-library|tv4&chd=t:100,98,72.1,66.8,50.1,15.1,6.1,3.8,1.2,0.7,0.2)](https://github.com/ebdrup/json-schema-benchmark/blob/master/README.md#performance) 161 104 [![performance](https://chart.googleapis.com/chart?chxt=x,y&cht=bhs&chco=76A4FB&chls=2.0&chbh=62,4,1&chs=600x416&chxl=-1:|ajv|@exodus/schemasafe|is-my-json-valid|djv|@cfworker/json-schema|jsonschema/=t:100,69.2,51.5,13.1,5.1,1.2)](https://github.com/ebdrup/json-schema-benchmark/blob/master/README.md#performance) 162 105 163 106 ## Features 164 107 165 - Ajv implements full JSON Schema [draft-06/07](http://json-schema.org/) and draft-04 standards: 166 - all validation keywords (see [JSON Schema validation keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md)) 167 - full support of remote refs (remote schemas have to be added with `addSchema` or compiled to be available) 168 - support of circular references between schemas 169 - correct string lengths for strings with unicode pairs (can be turned off) 170 - [formats](#formats) defined by JSON Schema draft-07 standard and custom formats (can be turned off) 171 - [validates schemas against meta-schema](#api-validateschema) 172 - supports [browsers](#using-in-browser) and Node.js 0.10-14.x 173 - [asynchronous loading](#asynchronous-schema-compilation) of referenced schemas during compilation 174 - "All errors" validation mode with [option allErrors](#options) 175 - [error messages with parameters](#validation-errors) describing error reasons to allow creating custom error messages 108 - Ajv implements JSON Schema [draft-06/07/2019-09/2020-12](http://json-schema.org/) standards (draft-04 is supported in v6): 109 - all validation keywords (see [JSON Schema validation keywords](https://ajv.js.org/json-schema.html)) 110 - [OpenAPI](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md) extensions: 111 - NEW: keyword [discriminator](https://ajv.js.org/json-schema.html#discriminator). 112 - keyword [nullable](https://ajv.js.org/json-schema.html#nullable). 113 - full support of remote references (remote schemas have to be added with `addSchema` or compiled to be available) 114 - support of recursive references between schemas 115 - correct string lengths for strings with unicode pairs 116 - JSON Schema [formats](https://ajv.js.org/guide/formats.html) (with [ajv-formats](https://github.com/ajv-validator/ajv-formats) plugin). 117 - [validates schemas against meta-schema](https://ajv.js.org/api.html#api-validateschema) 118 - NEW: supports [JSON Type Definition](https://datatracker.ietf.org/doc/rfc8927/): 119 - all keywords (see [JSON Type Definition schema forms](https://ajv.js.org/json-type-definition.html)) 120 - meta-schema for JTD schemas 121 - "union" keyword and user-defined keywords (can be used inside "metadata" member of the schema) 122 - supports [browsers](https://ajv.js.org/guide/environments.html#browsers) and Node.js 10.x - current 123 - [asynchronous loading](https://ajv.js.org/guide/managing-schemas.html#asynchronous-schema-loading) of referenced schemas during compilation 124 - "All errors" validation mode with [option allErrors](https://ajv.js.org/options.html#allerrors) 125 - [error messages with parameters](https://ajv.js.org/api.html#validation-errors) describing error reasons to allow error message generation 176 126 - i18n error messages support with [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package 177 - [filtering data](#filtering-data) from additional properties 178 - [assigning defaults](#assigning-defaults) to missing properties and items 179 - [coercing data](#coercing-data-types) to the types specified in `type` keywords 180 - [custom keywords](#defining-custom-keywords) 181 - draft-06/07 keywords `const`, `contains`, `propertyNames` and `if/then/else` 182 - draft-06 boolean schemas (`true`/`false` as a schema to always pass/fail). 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 184 - [$data reference](#data-reference) to use values from the validated data as values for the schema keywords 185 - [asynchronous validation](#asynchronous-validation) of custom formats and keywords 186 127 - [removing-additional-properties](https://ajv.js.org/guide/modifying-data.html#removing-additional-properties) 128 - [assigning defaults](https://ajv.js.org/guide/modifying-data.html#assigning-defaults) to missing properties and items 129 - [coercing data](https://ajv.js.org/guide/modifying-data.html#coercing-data-types) to the types specified in `type` keywords 130 - [user-defined keywords](https://ajv.js.org/guide/user-keywords.html) 131 - additional extension keywords with [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package 132 - [\$data reference](https://ajv.js.org/guide/combining-schemas.html#data-reference) to use values from the validated data as values for the schema keywords 133 - [asynchronous validation](https://ajv.js.org/guide/async-validation.html) of user-defined formats and keywords 187 134 188 135 ## Install 136 137 To install version 8: 189 138 190 139 ``` … … 192 141 ``` 193 142 194 195 143 ## <a name="usage"></a>Getting started 196 144 197 Try it in the Node.js REPL: https://tonicdev.com/npm/ajv 198 199 200 The fastest validation call: 145 Try it in the Node.js REPL: https://runkit.com/npm/ajv 146 147 In JavaScript: 201 148 202 149 ```javascript 150 // or ESM/TypeScript import 151 import Ajv from "ajv" 203 152 // Node.js require: 204 var Ajv = require('ajv'); 205 // or ESM/TypeScript import 206 import Ajv from 'ajv'; 207 208 var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true} 209 var validate = ajv.compile(schema); 210 var valid = validate(data); 211 if (!valid) console.log(validate.errors); 153 const Ajv = require("ajv") 154 155 const ajv = new Ajv() // options can be passed, e.g. {allErrors: true} 156 157 const schema = { 158 type: "object", 159 properties: { 160 foo: {type: "integer"}, 161 bar: {type: "string"}, 162 }, 163 required: ["foo"], 164 additionalProperties: false, 165 } 166 167 const data = { 168 foo: 1, 169 bar: "abc", 170 } 171 172 const validate = ajv.compile(schema) 173 const valid = validate(data) 174 if (!valid) console.log(validate.errors) 212 175 ``` 213 176 214 or with less code 215 216 ```javascript 217 // ... 218 var valid = ajv.validate(schema, data); 219 if (!valid) console.log(ajv.errors); 220 // ... 221 ``` 222 223 or 224 225 ```javascript 226 // ... 227 var valid = ajv.addSchema(schema, 'mySchema') 228 .validate('mySchema', data); 229 if (!valid) console.log(ajv.errorsText()); 230 // ... 231 ``` 232 233 See [API](#api) and [Options](#options) for more details. 234 235 Ajv compiles schemas to functions and caches them in all cases (using schema serialized with [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) or a custom function as a key), so that the next time the same schema is used (not necessarily the same object instance) it won't be compiled again. 236 237 The best performance is achieved when using compiled functions returned by `compile` or `getSchema` methods (there is no additional function call). 238 239 __Please note__: every time a validation function or `ajv.validate` are called `errors` property is overwritten. You need to copy `errors` array reference to another variable if you want to use it later (e.g., in the callback). See [Validation errors](#validation-errors) 240 241 __Note for TypeScript users__: `ajv` provides its own TypeScript declarations 242 out of the box, so you don't need to install the deprecated `@types/ajv` 243 module. 244 245 246 ## Using in browser 247 248 You can require Ajv directly from the code you browserify - in this case Ajv will be a part of your bundle. 249 250 If you need to use Ajv in several bundles you can create a separate UMD bundle using `npm run bundle` script (thanks to [siddo420](https://github.com/siddo420)). 251 252 Then you need to load Ajv in the browser: 253 ```html 254 <script src="ajv.min.js"></script> 255 ``` 256 257 This bundle can be used with different module systems; it creates global `Ajv` if no module system is found. 258 259 The browser bundle is available on [cdnjs](https://cdnjs.com/libraries/ajv). 260 261 Ajv is tested with these browsers: 262 263 [![Sauce Test Status](https://saucelabs.com/browser-matrix/epoberezkin.svg)](https://saucelabs.com/u/epoberezkin) 264 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. 276 277 278 ## Command line interface 279 280 CLI is available as a separate npm package [ajv-cli](https://github.com/ajv-validator/ajv-cli). It supports: 281 282 - compiling JSON Schemas to test their validity 283 - BETA: generating standalone module exporting a validation function to be used without Ajv (using [ajv-pack](https://github.com/ajv-validator/ajv-pack)) 284 - migrate schemas to draft-07 (using [json-schema-migrate](https://github.com/epoberezkin/json-schema-migrate)) 285 - validating data file(s) against JSON Schema 286 - testing expected validity of data against JSON Schema 287 - referenced schemas 288 - custom meta-schemas 289 - files in JSON, JSON5, YAML, and JavaScript format 290 - all Ajv options 291 - reporting changes in data after validation in [JSON-patch](https://tools.ietf.org/html/rfc6902) format 292 293 294 ## Validation keywords 295 296 Ajv supports all validation keywords from draft-07 of JSON Schema standard: 297 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) 305 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: 307 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. 310 311 See [JSON Schema validation keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md) for more details. 312 313 314 ## Annotation keywords 315 316 JSON Schema specification defines several annotation keywords that describe schema itself but do not perform any validation. 317 318 - `title` and `description`: information about the data represented by that schema 319 - `$comment` (NEW in draft-07): information for developers. With option `$comment` Ajv logs or passes the comment string to the user-supplied function. See [Options](#options). 320 - `default`: a default value of the data instance, see [Assigning defaults](#assigning-defaults). 321 - `examples` (NEW in draft-06): an array of data instances. Ajv does not check the validity of these instances against the schema. 322 - `readOnly` and `writeOnly` (NEW in draft-07): marks data-instance as read-only or write-only in relation to the source of the data (database, api, etc.). 323 - `contentEncoding`: [RFC 2045](https://tools.ietf.org/html/rfc2045#section-6.1 ), e.g., "base64". 324 - `contentMediaType`: [RFC 2046](https://tools.ietf.org/html/rfc2046), e.g., "image/png". 325 326 __Please note__: Ajv does not implement validation of the keywords `examples`, `contentEncoding` and `contentMediaType` but it reserves them. If you want to create a plugin that implements some of them, it should remove these keywords from the instance. 327 328 329 ## Formats 330 331 Ajv implements formats defined by JSON Schema specification and several other formats. It is recommended NOT to use "format" keyword implementations with untrusted data, as they use potentially unsafe regular expressions - see [ReDoS attack](#redos-attack). 332 333 __Please note__: if you need to use "format" keyword to validate untrusted data, you MUST assess their suitability and safety for your validation scenarios. 334 335 The following formats are implemented for string validation with "format" keyword: 336 337 - _date_: full-date according to [RFC3339](http://tools.ietf.org/html/rfc3339#section-5.6). 338 - _time_: time with optional time-zone. 339 - _date-time_: date-time from the same source (time-zone is mandatory). `date`, `time` and `date-time` validate ranges in `full` mode and only regexp in `fast` mode (see [options](#options)). 340 - _uri_: full URI. 341 - _uri-reference_: URI reference, including full and relative URIs. 342 - _uri-template_: URI template according to [RFC6570](https://tools.ietf.org/html/rfc6570) 343 - _url_ (deprecated): [URL record](https://url.spec.whatwg.org/#concept-url). 344 - _email_: email address. 345 - _hostname_: host name according to [RFC1034](http://tools.ietf.org/html/rfc1034#section-3.5). 346 - _ipv4_: IP address v4. 347 - _ipv6_: IP address v6. 348 - _regex_: tests whether a string is a valid regular expression by passing it to RegExp constructor. 349 - _uuid_: Universally Unique IDentifier according to [RFC4122](http://tools.ietf.org/html/rfc4122). 350 - _json-pointer_: JSON-pointer according to [RFC6901](https://tools.ietf.org/html/rfc6901). 351 - _relative-json-pointer_: relative JSON-pointer according to [this draft](http://tools.ietf.org/html/draft-luff-relative-json-pointer-00). 352 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. 354 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. 356 357 You can add additional formats and replace any of the formats above using [addFormat](#api-addformat) method. 358 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. 360 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). 362 363 364 ## <a name="ref"></a>Combining schemas with $ref 365 366 You can structure your validation logic across multiple schema files and have schemas reference each other using `$ref` keyword. 367 368 Example: 369 370 ```javascript 371 var schema = { 372 "$id": "http://example.com/schemas/schema.json", 373 "type": "object", 374 "properties": { 375 "foo": { "$ref": "defs.json#/definitions/int" }, 376 "bar": { "$ref": "defs.json#/definitions/str" } 377 } 378 }; 379 380 var defsSchema = { 381 "$id": "http://example.com/schemas/defs.json", 382 "definitions": { 383 "int": { "type": "integer" }, 384 "str": { "type": "string" } 385 } 386 }; 387 ``` 388 389 Now to compile your schema you can either pass all schemas to Ajv instance: 390 391 ```javascript 392 var ajv = new Ajv({schemas: [schema, defsSchema]}); 393 var validate = ajv.getSchema('http://example.com/schemas/schema.json'); 394 ``` 395 396 or use `addSchema` method: 397 398 ```javascript 399 var ajv = new Ajv; 400 var validate = ajv.addSchema(defsSchema) 401 .compile(schema); 402 ``` 403 404 See [Options](#options) and [addSchema](#api) method. 405 406 __Please note__: 407 - `$ref` is resolved as the uri-reference using schema $id as the base URI (see the example). 408 - References can be recursive (and mutually recursive) to implement the schemas for different data structures (such as linked lists, trees, graphs, etc.). 409 - You don't have to host your schema files at the URIs that you use as schema $id. These URIs are only used to identify the schemas, and according to JSON Schema specification validators should not expect to be able to download the schemas from these URIs. 410 - The actual location of the schema file in the file system is not used. 411 - You can pass the identifier of the schema as the second parameter of `addSchema` method or as a property name in `schemas` option. This identifier can be used instead of (or in addition to) schema $id. 412 - You cannot have the same $id (or the schema identifier) used for more than one schema - the exception will be thrown. 413 - You can implement dynamic resolution of the referenced schemas using `compileAsync` method. In this way you can store schemas in any system (files, web, database, etc.) and reference them without explicitly adding to Ajv instance. See [Asynchronous schema compilation](#asynchronous-schema-compilation). 414 415 416 ## $data reference 417 418 With `$data` option you can use values from the validated data as the values for the schema keywords. See [proposal](https://github.com/json-schema-org/json-schema-spec/issues/51) for more information about how it works. 419 420 `$data` reference is supported in the keywords: const, enum, format, maximum/minimum, exclusiveMaximum / exclusiveMinimum, maxLength / minLength, maxItems / minItems, maxProperties / minProperties, formatMaximum / formatMinimum, formatExclusiveMaximum / formatExclusiveMinimum, multipleOf, pattern, required, uniqueItems. 421 422 The value of "$data" should be a [JSON-pointer](https://tools.ietf.org/html/rfc6901) to the data (the root is always the top level data object, even if the $data reference is inside a referenced subschema) or a [relative JSON-pointer](http://tools.ietf.org/html/draft-luff-relative-json-pointer-00) (it is relative to the current point in data; if the $data reference is inside a referenced subschema it cannot point to the data outside of the root level for this subschema). 423 424 Examples. 425 426 This schema requires that the value in property `smaller` is less or equal than the value in the property larger: 427 428 ```javascript 429 var ajv = new Ajv({$data: true}); 430 431 var schema = { 432 "properties": { 433 "smaller": { 434 "type": "number", 435 "maximum": { "$data": "1/larger" } 436 }, 437 "larger": { "type": "number" } 438 } 439 }; 440 441 var validData = { 442 smaller: 5, 443 larger: 7 444 }; 445 446 ajv.validate(schema, validData); // true 447 ``` 448 449 This schema requires that the properties have the same format as their field names: 450 451 ```javascript 452 var schema = { 453 "additionalProperties": { 454 "type": "string", 455 "format": { "$data": "0#" } 456 } 457 }; 458 459 var validData = { 460 'date-time': '1963-06-19T08:30:06.283185Z', 461 email: 'joe.bloggs@example.com' 462 } 463 ``` 464 465 `$data` reference is resolved safely - it won't throw even if some property is undefined. If `$data` resolves to `undefined` the validation succeeds (with the exclusion of `const` keyword). If `$data` resolves to incorrect type (e.g. not "number" for maximum keyword) the validation fails. 466 467 468 ## $merge and $patch keywords 469 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). 471 472 To add keywords `$merge` and `$patch` to Ajv instance use this code: 473 474 ```javascript 475 require('ajv-merge-patch')(ajv); 476 ``` 477 478 Examples. 479 480 Using `$merge`: 481 482 ```json 483 { 484 "$merge": { 485 "source": { 486 "type": "object", 487 "properties": { "p": { "type": "string" } }, 488 "additionalProperties": false 489 }, 490 "with": { 491 "properties": { "q": { "type": "number" } } 492 } 493 } 494 } 495 ``` 496 497 Using `$patch`: 498 499 ```json 500 { 501 "$patch": { 502 "source": { 503 "type": "object", 504 "properties": { "p": { "type": "string" } }, 505 "additionalProperties": false 506 }, 507 "with": [ 508 { "op": "add", "path": "/properties/q", "value": { "type": "number" } } 509 ] 510 } 511 } 512 ``` 513 514 The schemas above are equivalent to this schema: 515 516 ```json 517 { 518 "type": "object", 519 "properties": { 520 "p": { "type": "string" }, 521 "q": { "type": "number" } 522 }, 523 "additionalProperties": false 524 } 525 ``` 526 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. 528 529 See the package [ajv-merge-patch](https://github.com/ajv-validator/ajv-merge-patch) for more information. 530 531 532 ## Defining custom keywords 533 534 The advantages of using custom keywords are: 535 536 - allow creating validation scenarios that cannot be expressed using JSON Schema 537 - simplify your schemas 538 - help bringing a bigger part of the validation logic to your schemas 539 - make your schemas more expressive, less verbose and closer to your application domain 540 - implement custom data processors that modify your data (`modifying` option MUST be used in keyword definition) and/or create side effects while the data is being validated 541 542 If a keyword is used only for side-effects and its validation result is pre-defined, use option `valid: true/false` in keyword definition to simplify both generated code (no error handling in case of `valid: true`) and your keyword functions (no need to return any validation result). 543 544 The concerns you have to be aware of when extending JSON Schema standard with custom keywords are the portability and understanding of your schemas. You will have to support these custom keywords on other platforms and to properly document these keywords so that everybody can understand them in your schemas. 545 546 You can define custom keywords with [addKeyword](#api-addkeyword) method. Keywords are defined on the `ajv` instance level - new instances will not have previously defined keywords. 547 548 Ajv allows defining keywords with: 549 - validation function 550 - compilation function 551 - macro function 552 - inline compilation function that should return code (as string) that will be inlined in the currently compiled schema. 553 554 Example. `range` and `exclusiveRange` keywords using compiled schema: 555 556 ```javascript 557 ajv.addKeyword('range', { 558 type: 'number', 559 compile: function (sch, parentSchema) { 560 var min = sch[0]; 561 var max = sch[1]; 562 563 return parentSchema.exclusiveRange === true 564 ? function (data) { return data > min && data < max; } 565 : function (data) { return data >= min && data <= max; } 566 } 567 }); 568 569 var schema = { "range": [2, 4], "exclusiveRange": true }; 570 var validate = ajv.compile(schema); 571 console.log(validate(2.01)); // true 572 console.log(validate(3.99)); // true 573 console.log(validate(2)); // false 574 console.log(validate(4)); // false 575 ``` 576 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. 578 579 See [Defining custom keywords](https://github.com/ajv-validator/ajv/blob/master/CUSTOM.md) for more details. 580 581 582 ## Asynchronous schema compilation 583 584 During asynchronous compilation remote references are loaded using supplied function. See `compileAsync` [method](#api-compileAsync) and `loadSchema` [option](#options). 585 586 Example: 587 588 ```javascript 589 var ajv = new Ajv({ loadSchema: loadSchema }); 590 591 ajv.compileAsync(schema).then(function (validate) { 592 var valid = validate(data); 593 // ... 594 }); 595 596 function loadSchema(uri) { 597 return request.json(uri).then(function (res) { 598 if (res.statusCode >= 400) 599 throw new Error('Loading error: ' + res.statusCode); 600 return res.body; 601 }); 602 } 603 ``` 604 605 __Please note__: [Option](#options) `missingRefs` should NOT be set to `"ignore"` or `"fail"` for asynchronous compilation to work. 606 607 608 ## Asynchronous validation 609 610 Example in Node.js REPL: https://tonicdev.com/esp/ajv-asynchronous-validation 611 612 You can define custom formats and keywords that perform validation asynchronously by accessing database or some other service. You should add `async: true` in the keyword or format definition (see [addFormat](#api-addformat), [addKeyword](#api-addkeyword) and [Defining custom keywords](#defining-custom-keywords)). 613 614 If your schema uses asynchronous formats/keywords or refers to some schema that contains them it should have `"$async": true` keyword so that Ajv can compile it correctly. If asynchronous format/keyword or reference to asynchronous schema is used in the schema without `$async` keyword Ajv will throw an exception during schema compilation. 615 616 __Please note__: all asynchronous subschemas that are referenced from the current or other schemas should have `"$async": true` keyword as well, otherwise the schema compilation will fail. 617 618 Validation function for an asynchronous custom format/keyword should return a promise that resolves with `true` or `false` (or rejects with `new Ajv.ValidationError(errors)` if you want to return custom errors from the keyword function). 619 620 Ajv compiles asynchronous schemas to [es7 async functions](http://tc39.github.io/ecmascript-asyncawait/) that can optionally be transpiled with [nodent](https://github.com/MatAtBread/nodent). Async functions are supported in Node.js 7+ and all modern browsers. You can also supply any other transpiler as a function via `processCode` option. See [Options](#options). 621 622 The compiled validation function has `$async: true` property (if the schema is asynchronous), so you can differentiate these functions if you are using both synchronous and asynchronous schemas. 623 624 Validation result will be a promise that resolves with validated data or rejects with an exception `Ajv.ValidationError` that contains the array of validation errors in `errors` property. 625 626 627 Example: 628 629 ```javascript 630 var ajv = new Ajv; 631 // require('ajv-async')(ajv); 632 633 ajv.addKeyword('idExists', { 634 async: true, 635 type: 'number', 636 validate: checkIdExists 637 }); 638 639 640 function checkIdExists(schema, data) { 641 return knex(schema.table) 642 .select('id') 643 .where('id', data) 644 .then(function (rows) { 645 return !!rows.length; // true if record is found 646 }); 647 } 648 649 var schema = { 650 "$async": true, 651 "properties": { 652 "userId": { 653 "type": "integer", 654 "idExists": { "table": "users" } 655 }, 656 "postId": { 657 "type": "integer", 658 "idExists": { "table": "posts" } 659 } 660 } 661 }; 662 663 var validate = ajv.compile(schema); 664 665 validate({ userId: 1, postId: 19 }) 666 .then(function (data) { 667 console.log('Data is valid', data); // { userId: 1, postId: 19 } 668 }) 669 .catch(function (err) { 670 if (!(err instanceof Ajv.ValidationError)) throw err; 671 // data is invalid 672 console.log('Validation errors:', err.errors); 673 }); 674 ``` 675 676 ### Using transpilers with asynchronous validation functions. 677 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). 679 680 681 #### Using nodent 682 683 ```javascript 684 var ajv = new Ajv; 685 require('ajv-async')(ajv); 686 // in the browser if you want to load ajv-async bundle separately you can: 687 // window.ajvAsync(ajv); 688 var validate = ajv.compile(schema); // transpiled es7 async function 689 validate(data).then(successFunc).catch(errorFunc); 690 ``` 691 692 693 #### Using other transpilers 694 695 ```javascript 696 var ajv = new Ajv({ processCode: transpileFunc }); 697 var validate = ajv.compile(schema); // transpiled es7 async function 698 validate(data).then(successFunc).catch(errorFunc); 699 ``` 700 701 See [Options](#options). 702 703 704 ## Security considerations 705 706 JSON Schema, if properly used, can replace data sanitisation. It doesn't replace other API security considerations. It also introduces additional security aspects to consider. 707 708 709 ##### Security contact 177 Learn how to use Ajv and see more examples in the [Guide: getting started](https://ajv.js.org/guide/getting-started.html) 178 179 ## Changes history 180 181 See [https://github.com/ajv-validator/ajv/releases](https://github.com/ajv-validator/ajv/releases) 182 183 **Please note**: [Changes in version 8.0.0](https://github.com/ajv-validator/ajv/releases/tag/v8.0.0) 184 185 [Version 7.0.0](https://github.com/ajv-validator/ajv/releases/tag/v7.0.0) 186 187 [Version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0). 188 189 ## Code of conduct 190 191 Please review and follow the [Code of conduct](./CODE_OF_CONDUCT.md). 192 193 Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team. 194 195 ## Security contact 710 196 711 197 To report a security vulnerability, please use the … … 713 199 Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues. 714 200 715 716 ##### Untrusted schemas717 718 Ajv treats JSON schemas as trusted as your application code. This security model is based on the most common use case, when the schemas are static and bundled together with the application.719 720 If your schemas are received from untrusted sources (or generated from untrusted data) there are several scenarios you need to prevent:721 - compiling schemas can cause stack overflow (if they are too deep)722 - compiling schemas can be slow (e.g. [#557](https://github.com/ajv-validator/ajv/issues/557))723 - validating certain data can be slow724 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.726 727 Regardless the measures you take, using untrusted schemas increases security risks.728 729 730 ##### Circular references in JavaScript objects731 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).733 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.735 736 737 ##### Security risks of trusted schemas738 739 Some keywords in JSON Schemas can lead to very slow validation for certain data. These keywords include (but may be not limited to):740 741 - `pattern` and `format` for large strings - in some cases using `maxLength` can help mitigate it, but certain regular expressions can lead to exponential validation time even with relatively short strings (see [ReDoS attack](#redos-attack)).742 - `patternProperties` for large property names - use `propertyNames` to mitigate, but some regular expressions can have exponential evaluation time as well.743 - `uniqueItems` for large non-scalar arrays - use `maxItems` to mitigate744 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).746 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:748 749 ```javascript750 const isSchemaSecure = ajv.compile(require('ajv/lib/refs/json-schema-secure.json'));751 752 const schema1 = {format: 'email'};753 isSchemaSecure(schema1); // false754 755 const schema2 = {format: 'email', maxLength: MAX_LENGTH};756 isSchemaSecure(schema2); // true757 ```758 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.760 761 762 ##### Content Security Policies (CSP)763 See [Ajv and Content Security Policies (CSP)](#ajv-and-content-security-policies-csp)764 765 766 ## ReDoS attack767 768 Certain regular expressions can lead to the exponential evaluation time even with relatively short strings.769 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.771 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:773 774 - making assessment of "format" implementations in Ajv.775 - using `format: 'fast'` option that simplifies some of the regular expressions (although it does not guarantee that they are safe).776 - replacing format implementations provided by Ajv with your own implementations of "format" keyword that either uses different regular expressions or another approach to format validation. Please see [addFormat](#api-addformat) method.777 - disabling format validation by ignoring "format" keyword with option `format: false`778 779 Whatever mitigation you choose, please assume all formats provided by Ajv as potentially unsafe and make your own assessment of their suitability for your validation scenarios.780 781 782 ## Filtering data783 784 With [option `removeAdditional`](#options) (added by [andyscott](https://github.com/andyscott)) you can filter data during the validation.785 786 This option modifies original data.787 788 Example:789 790 ```javascript791 var ajv = new Ajv({ removeAdditional: true });792 var schema = {793 "additionalProperties": false,794 "properties": {795 "foo": { "type": "number" },796 "bar": {797 "additionalProperties": { "type": "number" },798 "properties": {799 "baz": { "type": "string" }800 }801 }802 }803 }804 805 var data = {806 "foo": 0,807 "additional1": 1, // will be removed; `additionalProperties` == false808 "bar": {809 "baz": "abc",810 "additional2": 2 // will NOT be removed; `additionalProperties` != false811 },812 }813 814 var validate = ajv.compile(schema);815 816 console.log(validate(data)); // true817 console.log(data); // { "foo": 0, "bar": { "baz": "abc", "additional2": 2 }818 ```819 820 If `removeAdditional` option in the example above were `"all"` then both `additional1` and `additional2` properties would have been removed.821 822 If the option were `"failing"` then property `additional1` would have been removed regardless of its value and property `additional2` would have been removed only if its value were failing the schema in the inner `additionalProperties` (so in the example above it would have stayed because it passes the schema, but any non-number would have been removed).823 824 __Please note__: If you use `removeAdditional` option with `additionalProperties` keyword inside `anyOf`/`oneOf` keywords your validation can fail with this schema, for example:825 826 ```json827 {828 "type": "object",829 "oneOf": [830 {831 "properties": {832 "foo": { "type": "string" }833 },834 "required": [ "foo" ],835 "additionalProperties": false836 },837 {838 "properties": {839 "bar": { "type": "integer" }840 },841 "required": [ "bar" ],842 "additionalProperties": false843 }844 ]845 }846 ```847 848 The intention of the schema above is to allow objects with either the string property "foo" or the integer property "bar", but not with both and not with any other properties.849 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).851 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:853 854 ```json855 {856 "type": "object",857 "properties": {858 "foo": { "type": "string" },859 "bar": { "type": "integer" }860 },861 "additionalProperties": false,862 "oneOf": [863 { "required": [ "foo" ] },864 { "required": [ "bar" ] }865 ]866 }867 ```868 869 The schema above is also more efficient - it will compile into a faster function.870 871 872 ## Assigning defaults873 874 With [option `useDefaults`](#options) Ajv will assign values from `default` keyword in the schemas of `properties` and `items` (when it is the array of schemas) to the missing properties and items.875 876 With the option value `"empty"` properties and items equal to `null` or `""` (empty string) will be considered missing and assigned defaults.877 878 This option modifies original data.879 880 __Please note__: the default value is inserted in the generated validation code as a literal, so the value inserted in the data will be the deep clone of the default in the schema.881 882 883 Example 1 (`default` in `properties`):884 885 ```javascript886 var ajv = new Ajv({ useDefaults: true });887 var schema = {888 "type": "object",889 "properties": {890 "foo": { "type": "number" },891 "bar": { "type": "string", "default": "baz" }892 },893 "required": [ "foo", "bar" ]894 };895 896 var data = { "foo": 1 };897 898 var validate = ajv.compile(schema);899 900 console.log(validate(data)); // true901 console.log(data); // { "foo": 1, "bar": "baz" }902 ```903 904 Example 2 (`default` in `items`):905 906 ```javascript907 var schema = {908 "type": "array",909 "items": [910 { "type": "number" },911 { "type": "string", "default": "foo" }912 ]913 }914 915 var data = [ 1 ];916 917 var validate = ajv.compile(schema);918 919 console.log(validate(data)); // true920 console.log(data); // [ 1, "foo" ]921 ```922 923 `default` keywords in other cases are ignored:924 925 - not in `properties` or `items` subschemas926 - in schemas inside `anyOf`, `oneOf` and `not` (see [#42](https://github.com/ajv-validator/ajv/issues/42))927 - in `if` subschema of `switch` keyword928 - in schemas generated by custom macro keywords929 930 The [`strictDefaults` option](#options) customizes Ajv's behavior for the defaults that Ajv ignores (`true` raises an error, and `"log"` outputs a warning).931 932 933 ## Coercing data types934 935 When you are validating user inputs all your data properties are usually strings. The option `coerceTypes` allows you to have your data types coerced to the types specified in your schema `type` keywords, both to pass the validation and to use the correctly typed data afterwards.936 937 This option modifies original data.938 939 __Please note__: if you pass a scalar value to the validating function its type will be coerced and it will pass the validation, but the value of the variable you pass won't be updated because scalars are passed by value.940 941 942 Example 1:943 944 ```javascript945 var ajv = new Ajv({ coerceTypes: true });946 var schema = {947 "type": "object",948 "properties": {949 "foo": { "type": "number" },950 "bar": { "type": "boolean" }951 },952 "required": [ "foo", "bar" ]953 };954 955 var data = { "foo": "1", "bar": "false" };956 957 var validate = ajv.compile(schema);958 959 console.log(validate(data)); // true960 console.log(data); // { "foo": 1, "bar": false }961 ```962 963 Example 2 (array coercions):964 965 ```javascript966 var ajv = new Ajv({ coerceTypes: 'array' });967 var schema = {968 "properties": {969 "foo": { "type": "array", "items": { "type": "number" } },970 "bar": { "type": "boolean" }971 }972 };973 974 var data = { "foo": "1", "bar": ["false"] };975 976 var validate = ajv.compile(schema);977 978 console.log(validate(data)); // true979 console.log(data); // { "foo": [1], "bar": false }980 ```981 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).983 984 See [Coercion rules](https://github.com/ajv-validator/ajv/blob/master/COERCION.md) for details.985 986 987 ## API988 989 ##### new Ajv(Object options) -> Object990 991 Create Ajv instance.992 993 994 ##### .compile(Object schema) -> Function<Object data>995 996 Generate validating function and cache the compiled schema for future use.997 998 Validating function returns a boolean value. This function has properties `errors` and `schema`. Errors encountered during the last validation are assigned to `errors` property (it is assigned `null` if there was no errors). `schema` property contains the reference to the original schema.999 1000 The schema passed to this method will be validated against meta-schema unless `validateSchema` option is false. If schema is invalid, an error will be thrown. See [options](#options).1001 1002 1003 ##### <a name="api-compileAsync"></a>.compileAsync(Object schema [, Boolean meta] [, Function callback]) -> Promise1004 1005 Asynchronous version of `compile` method that loads missing remote schemas using asynchronous function in `options.loadSchema`. This function returns a Promise that resolves to a validation function. An optional callback passed to `compileAsync` will be called with 2 parameters: error (or null) and validating function. The returned promise will reject (and the callback will be called with an error) when:1006 1007 - missing schema can't be loaded (`loadSchema` returns a Promise that rejects).1008 - a schema containing a missing reference is loaded, but the reference cannot be resolved.1009 - schema (or some loaded/referenced schema) is invalid.1010 1011 The function compiles schema and loads the first missing schema (or meta-schema) until all missing schemas are loaded.1012 1013 You can asynchronously compile meta-schema by passing `true` as the second parameter.1014 1015 See example in [Asynchronous compilation](#asynchronous-schema-compilation).1016 1017 1018 ##### .validate(Object schema|String key|String ref, data) -> Boolean1019 1020 Validate data using passed schema (it will be compiled and cached).1021 1022 Instead of the schema you can use the key that was previously passed to `addSchema`, the schema id if it was present in the schema or any previously resolved reference.1023 1024 Validation errors will be available in the `errors` property of Ajv instance (`null` if there were no errors).1025 1026 __Please note__: every time this method is called the errors are overwritten so you need to copy them to another variable if you want to use them later.1027 1028 If the schema is asynchronous (has `$async` keyword on the top level) this method returns a Promise. See [Asynchronous validation](#asynchronous-validation).1029 1030 1031 ##### .addSchema(Array<Object>|Object schema [, String key]) -> Ajv1032 1033 Add schema(s) to validator instance. This method does not compile schemas (but it still validates them). Because of that dependencies can be added in any order and circular dependencies are supported. It also prevents unnecessary compilation of schemas that are containers for other schemas but not used as a whole.1034 1035 Array of schemas can be passed (schemas should have ids), the second parameter will be ignored.1036 1037 Key can be passed that can be used to reference the schema and will be used as the schema id if there is no id inside the schema. If the key is not passed, the schema id will be used as the key.1038 1039 1040 Once the schema is added, it (and all the references inside it) can be referenced in other schemas and used to validate data.1041 1042 Although `addSchema` does not compile schemas, explicit compilation is not required - the schema will be compiled when it is used first time.1043 1044 By default the schema is validated against meta-schema before it is added, and if the schema does not pass validation the exception is thrown. This behaviour is controlled by `validateSchema` option.1045 1046 __Please note__: Ajv uses the [method chaining syntax](https://en.wikipedia.org/wiki/Method_chaining) for all methods with the prefix `add*` and `remove*`.1047 This allows you to do nice things like the following.1048 1049 ```javascript1050 var validate = new Ajv().addSchema(schema).addFormat(name, regex).getSchema(uri);1051 ```1052 1053 ##### .addMetaSchema(Array<Object>|Object schema [, String key]) -> Ajv1054 1055 Adds meta schema(s) that can be used to validate other schemas. That function should be used instead of `addSchema` because there may be instance options that would compile a meta schema incorrectly (at the moment it is `removeAdditional` option).1056 1057 There is no need to explicitly add draft-07 meta schema (http://json-schema.org/draft-07/schema) - it is added by default, unless option `meta` is set to `false`. You only need to use it if you have a changed meta-schema that you want to use to validate your schemas. See `validateSchema`.1058 1059 1060 ##### <a name="api-validateschema"></a>.validateSchema(Object schema) -> Boolean1061 1062 Validates schema. This method should be used to validate schemas rather than `validate` due to the inconsistency of `uri` format in JSON Schema standard.1063 1064 By default this method is called automatically when the schema is added, so you rarely need to use it directly.1065 1066 If schema doesn't have `$schema` property, it is validated against draft 6 meta-schema (option `meta` should not be false).1067 1068 If schema has `$schema` property, then the schema with this id (that should be previously added) is used to validate passed schema.1069 1070 Errors will be available at `ajv.errors`.1071 1072 1073 ##### .getSchema(String key) -> Function<Object data>1074 1075 Retrieve compiled schema previously added with `addSchema` by the key passed to `addSchema` or by its full reference (id). The returned validating function has `schema` property with the reference to the original schema.1076 1077 1078 ##### .removeSchema([Object schema|String key|String ref|RegExp pattern]) -> Ajv1079 1080 Remove added/cached schema. Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references.1081 1082 Schema can be removed using:1083 - key passed to `addSchema`1084 - it's full reference (id)1085 - RegExp that should match schema id or key (meta-schemas won't be removed)1086 - actual schema object that will be stable-stringified to remove schema from cache1087 1088 If no parameter is passed all schemas but meta-schemas will be removed and the cache will be cleared.1089 1090 1091 ##### <a name="api-addformat"></a>.addFormat(String name, String|RegExp|Function|Object format) -> Ajv1092 1093 Add custom format to validate strings or numbers. It can also be used to replace pre-defined formats for Ajv instance.1094 1095 Strings are converted to RegExp.1096 1097 Function should return validation result as `true` or `false`.1098 1099 If object is passed it should have properties `validate`, `compare` and `async`:1100 1101 - _validate_: a string, RegExp or a function as described above.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.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`.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.1105 1106 Custom formats can be also added via `formats` option.1107 1108 1109 ##### <a name="api-addkeyword"></a>.addKeyword(String keyword, Object definition) -> Ajv1110 1111 Add custom validation keyword to Ajv instance.1112 1113 Keyword should be different from all standard JSON Schema keywords and different from previously defined keywords. There is no way to redefine keywords or to remove keyword definition from the instance.1114 1115 Keyword must start with a letter, `_` or `$`, and may continue with letters, numbers, `_`, `$`, or `-`.1116 It is recommended to use an application-specific prefix for keywords to avoid current and future name collisions.1117 1118 Example Keywords:1119 - `"xyz-example"`: valid, and uses prefix for the xyz project to avoid name collisions.1120 - `"example"`: valid, but not recommended as it could collide with future versions of JSON Schema etc.1121 - `"3-example"`: invalid as numbers are not allowed to be the first character in a keyword1122 1123 Keyword definition is an object with the following properties:1124 1125 - _type_: optional string or array of strings with data type(s) that the keyword applies to. If not present, the keyword will apply to all types.1126 - _validate_: validating function1127 - _compile_: compiling function1128 - _macro_: macro function1129 - _inline_: compiling function that returns code (as string)1130 - _schema_: an optional `false` value used with "validate" keyword to not pass schema1131 - _metaSchema_: an optional meta-schema for keyword schema1132 - _dependencies_: an optional list of properties that must be present in the parent schema - it will be checked during schema compilation1133 - _modifying_: `true` MUST be passed if keyword modifies data1134 - _statements_: `true` can be passed in case inline keyword generates statements (as opposed to expression)1135 - _valid_: pass `true`/`false` to pre-define validation result, the result returned from validation function will be ignored. This option cannot be used with macro keywords.1136 - _$data_: an optional `true` value to support [$data reference](#data-reference) as the value of custom keyword. The reference will be resolved at validation time. If the keyword has meta-schema it would be extended to allow $data and it will be used to validate the resolved value. Supporting $data reference requires that keyword has validating function (as the only option or in addition to compile, macro or inline function).1137 - _async_: an optional `true` value if the validation function is asynchronous (whether it is compiled or passed in _validate_ property); in this case it should return a promise that resolves with a value `true` or `false`. This option is ignored in case of "macro" and "inline" keywords.1138 - _errors_: an optional boolean or string `"full"` indicating whether keyword returns errors. If this property is not set Ajv will determine if the errors were set in case of failed validation.1139 1140 _compile_, _macro_ and _inline_ are mutually exclusive, only one should be used at a time. _validate_ can be used separately or in addition to them to support $data reference.1141 1142 __Please note__: If the keyword is validating data type that is different from the type(s) in its definition, the validation function will not be called (and expanded macro will not be used), so there is no need to check for data type inside validation function or inside schema returned by macro function (unless you want to enforce a specific type and for some reason do not want to use a separate `type` keyword for that). In the same way as standard keywords work, if the keyword does not apply to the data type being validated, the validation of this keyword will succeed.1143 1144 See [Defining custom keywords](#defining-custom-keywords) for more details.1145 1146 1147 ##### .getKeyword(String keyword) -> Object|Boolean1148 1149 Returns custom keyword definition, `true` for pre-defined keywords and `false` if the keyword is unknown.1150 1151 1152 ##### .removeKeyword(String keyword) -> Ajv1153 1154 Removes custom or pre-defined keyword so you can redefine them.1155 1156 While this method can be used to extend pre-defined keywords, it can also be used to completely change their meaning - it may lead to unexpected results.1157 1158 __Please note__: schemas compiled before the keyword is removed will continue to work without changes. To recompile schemas use `removeSchema` method and compile them again.1159 1160 1161 ##### .errorsText([Array<Object> errors [, Object options]]) -> String1162 1163 Returns the text with all errors in a String.1164 1165 Options can have properties `separator` (string used to separate errors, ", " by default) and `dataVar` (the variable name that dataPaths are prefixed with, "data" by default).1166 1167 1168 ## Options1169 1170 Defaults:1171 1172 ```javascript1173 {1174 // validation and reporting options:1175 $data: false,1176 allErrors: false,1177 verbose: false,1178 $comment: false, // NEW in Ajv version 6.01179 jsonPointers: false,1180 uniqueItems: true,1181 unicode: true,1182 nullable: false,1183 format: 'fast',1184 formats: {},1185 unknownFormats: true,1186 schemas: {},1187 logger: undefined,1188 // referenced schema options:1189 schemaId: '$id',1190 missingRefs: true,1191 extendRefs: 'ignore', // recommended 'fail'1192 loadSchema: undefined, // function(uri: string): Promise {}1193 // options to modify validated data:1194 removeAdditional: false,1195 useDefaults: false,1196 coerceTypes: false,1197 // strict mode options1198 strictDefaults: false,1199 strictKeywords: false,1200 strictNumbers: false,1201 // asynchronous validation options:1202 transpile: undefined, // requires ajv-async package1203 // advanced options:1204 meta: true,1205 validateSchema: true,1206 addUsedSchema: true,1207 inlineRefs: true,1208 passContext: false,1209 loopRequired: Infinity,1210 ownProperties: false,1211 multipleOfPrecision: false,1212 errorDataPath: 'object', // deprecated1213 messages: true,1214 sourceCode: false,1215 processCode: undefined, // function (str: string, schema: object): string {}1216 cache: new Cache,1217 serialize: undefined1218 }1219 ```1220 1221 ##### Validation and reporting options1222 1223 - _$data_: support [$data references](#data-reference). Draft 6 meta-schema that is added by default will be extended to allow them. If you want to use another meta-schema you need to use $dataMetaSchema method to add support for $data reference. See [API](#api).1224 - _allErrors_: check all rules collecting all errors. Default is to return after the first error.1225 - _verbose_: include the reference to the part of the schema (`schema` and `parentSchema`) and validated data in errors (false by default).1226 - _$comment_ (NEW in Ajv version 6.0): log or pass the value of `$comment` keyword to a function. Option values:1227 - `false` (default): ignore $comment keyword.1228 - `true`: log the keyword value to console.1229 - function: pass the keyword value, its schema path and root schema to the specified function1230 - _jsonPointers_: set `dataPath` property of errors using [JSON Pointers](https://tools.ietf.org/html/rfc6901) instead of JavaScript property access notation.1231 - _uniqueItems_: validate `uniqueItems` keyword (true by default).1232 - _unicode_: calculate correct length of strings with unicode pairs (true by default). Pass `false` to use `.length` of strings that is faster, but gives "incorrect" lengths of strings with unicode pairs - each unicode pair is counted as two characters.1233 - _nullable_: support keyword "nullable" from [Open API 3 specification](https://swagger.io/docs/specification/data-models/data-types/).1234 - _format_: formats validation mode. Option values:1235 - `"fast"` (default) - simplified and fast validation (see [Formats](#formats) for details of which formats are available and affected by this option).1236 - `"full"` - more restrictive and slow validation. E.g., 25:00:00 and 2015/14/33 will be invalid time and date in 'full' mode but it will be valid in 'fast' mode.1237 - `false` - ignore all format keywords.1238 - _formats_: an object with custom formats. Keys and values will be passed to `addFormat` method.1239 - _keywords_: an object with custom keywords. Keys and values will be passed to `addKeyword` method.1240 - _unknownFormats_: handling of unknown formats. Option values:1241 - `true` (default) - if an unknown format is encountered the exception is thrown during schema compilation. If `format` keyword value is [$data reference](#data-reference) and it is unknown the validation will fail.1242 - `[String]` - an array of unknown format names that will be ignored. This option can be used to allow usage of third party schemas with format(s) for which you don't have definitions, but still fail if another unknown format is used. If `format` keyword value is [$data reference](#data-reference) and it is not in this array the validation will fail.1243 - `"ignore"` - to log warning during schema compilation and always pass validation (the default behaviour in versions before 5.0.0). This option is not recommended, as it allows to mistype format name and it won't be validated without any error message. This behaviour is required by JSON Schema specification.1244 - _schemas_: an array or object of schemas that will be added to the instance. In case you pass the array the schemas must have IDs in them. When the object is passed the method `addSchema(value, key)` will be called for each schema in this object.1245 - _logger_: sets the logging method. Default is the global `console` object that should have methods `log`, `warn` and `error`. See [Error logging](#error-logging). Option values:1246 - custom logger - it should have methods `log`, `warn` and `error`. If any of these methods is missing an exception will be thrown.1247 - `false` - logging is disabled.1248 1249 1250 ##### Referenced schema options1251 1252 - _schemaId_: this option defines which keywords are used as schema URI. Option value:1253 - `"$id"` (default) - only use `$id` keyword as schema URI (as specified in JSON Schema draft-06/07), ignore `id` keyword (if it is present a warning will be logged).1254 - `"id"` - only use `id` keyword as schema URI (as specified in JSON Schema draft-04), ignore `$id` keyword (if it is present a warning will be logged).1255 - `"auto"` - use both `$id` and `id` keywords as schema URI. If both are present (in the same schema object) and different the exception will be thrown during schema compilation.1256 - _missingRefs_: handling of missing referenced schemas. Option values:1257 - `true` (default) - if the reference cannot be resolved during compilation the exception is thrown. The thrown error has properties `missingRef` (with hash fragment) and `missingSchema` (without it). Both properties are resolved relative to the current base id (usually schema id, unless it was substituted).1258 - `"ignore"` - to log error during compilation and always pass validation.1259 - `"fail"` - to log error and successfully compile schema but fail validation if this rule is checked.1260 - _extendRefs_: validation of other keywords when `$ref` is present in the schema. Option values:1261 - `"ignore"` (default) - when `$ref` is used other keywords are ignored (as per [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3) standard). A warning will be logged during the schema compilation.1262 - `"fail"` (recommended) - if other validation keywords are used together with `$ref` the exception will be thrown when the schema is compiled. This option is recommended to make sure schema has no keywords that are ignored, which can be confusing.1263 - `true` - validate all keywords in the schemas with `$ref` (the default behaviour in versions before 5.0.0).1264 - _loadSchema_: asynchronous function that will be used to load remote schemas when `compileAsync` [method](#api-compileAsync) is used and some reference is missing (option `missingRefs` should NOT be 'fail' or 'ignore'). This function should accept remote schema uri as a parameter and return a Promise that resolves to a schema. See example in [Asynchronous compilation](#asynchronous-schema-compilation).1265 1266 1267 ##### Options to modify validated data1268 1269 - _removeAdditional_: remove additional properties - see example in [Filtering data](#filtering-data). This option is not used if schema is added with `addMetaSchema` method. Option values:1270 - `false` (default) - not to remove additional properties1271 - `"all"` - all additional properties are removed, regardless of `additionalProperties` keyword in schema (and no validation is made for them).1272 - `true` - only additional properties with `additionalProperties` keyword equal to `false` are removed.1273 - `"failing"` - additional properties that fail schema validation will be removed (where `additionalProperties` keyword is `false` or schema).1274 - _useDefaults_: replace missing or undefined properties and items with the values from corresponding `default` keywords. Default behaviour is to ignore `default` keywords. This option is not used if schema is added with `addMetaSchema` method. See examples in [Assigning defaults](#assigning-defaults). Option values:1275 - `false` (default) - do not use defaults1276 - `true` - insert defaults by value (object literal is used).1277 - `"empty"` - in addition to missing or undefined, use defaults for properties and items that are equal to `null` or `""` (an empty string).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.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:1280 - `false` (default) - no type coercion.1281 - `true` - coerce scalar data types.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).1283 1284 1285 ##### Strict mode options1286 1287 - _strictDefaults_: report ignored `default` keywords in schemas. Option values:1288 - `false` (default) - ignored defaults are not reported1289 - `true` - if an ignored default is present, throw an error1290 - `"log"` - if an ignored default is present, log warning1291 - _strictKeywords_: report unknown keywords in schemas. Option values:1292 - `false` (default) - unknown keywords are not reported1293 - `true` - if an unknown keyword is present, throw an error1294 - `"log"` - if an unknown keyword is present, log warning1295 - _strictNumbers_: validate numbers strictly, failing validation for NaN and Infinity. Option values:1296 - `false` (default) - NaN or Infinity will pass validation for numeric types1297 - `true` - NaN or Infinity will not pass validation for numeric types1298 1299 ##### Asynchronous validation options1300 1301 - _transpile_: Requires [ajv-async](https://github.com/ajv-validator/ajv-async) package. It determines whether Ajv transpiles compiled asynchronous validation function. Option values:1302 - `undefined` (default) - transpile with [nodent](https://github.com/MatAtBread/nodent) if async functions are not supported.1303 - `true` - always transpile with nodent.1304 - `false` - do not transpile; if async functions are not supported an exception will be thrown.1305 1306 1307 ##### Advanced options1308 1309 - _meta_: add [meta-schema](http://json-schema.org/documentation.html) so it can be used by other schemas (true by default). If an object is passed, it will be used as the default meta-schema for schemas that have no `$schema` keyword. This default meta-schema MUST have `$schema` keyword.1310 - _validateSchema_: validate added/compiled schemas against meta-schema (true by default). `$schema` property in the schema can be http://json-schema.org/draft-07/schema or absent (draft-07 meta-schema will be used) or can be a reference to the schema previously added with `addMetaSchema` method. Option values:1311 - `true` (default) - if the validation fails, throw the exception.1312 - `"log"` - if the validation fails, log error.1313 - `false` - skip schema validation.1314 - _addUsedSchema_: by default methods `compile` and `validate` add schemas to the instance if they have `$id` (or `id`) property that doesn't start with "#". If `$id` is present and it is not unique the exception will be thrown. Set this option to `false` to skip adding schemas to the instance and the `$id` uniqueness check when these methods are used. This option does not affect `addSchema` method.1315 - _inlineRefs_: Affects compilation of referenced schemas. Option values:1316 - `true` (default) - the referenced schemas that don't have refs in them are inlined, regardless of their size - that substantially improves performance at the cost of the bigger size of compiled schema functions.1317 - `false` - to not inline referenced schemas (they will be compiled as separate functions).1318 - integer number - to limit the maximum number of keywords of the schema that will be inlined.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.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.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.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).1323 - _errorDataPath_ (deprecated): set `dataPath` to point to 'object' (default) or to 'property' when validating keywords `required`, `additionalProperties` and `dependencies`.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)).1325 - _sourceCode_: add `sourceCode` property to validating function (for debugging; this code can be different from the result of toString call).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: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.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()`.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.1331 1332 1333 ## Validation errors1334 1335 In case of validation failure, Ajv assigns the array of errors to `errors` property of validation function (or to `errors` property of Ajv instance when `validate` or `validateSchema` methods were called). In case of [asynchronous validation](#asynchronous-validation), the returned promise is rejected with exception `Ajv.ValidationError` that has `errors` property.1336 1337 1338 ### Error objects1339 1340 Each error is an object with the following properties:1341 1342 - _keyword_: validation keyword.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"`).1344 - _schemaPath_: the path (JSON-pointer as a URI fragment) to the schema of the keyword that failed validation.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.1346 - _message_: the standard error message (can be excluded with option `messages` set to false).1347 - _schema_: the schema of the keyword (added with `verbose` option).1348 - _parentSchema_: the schema containing the keyword (added with `verbose` option)1349 - _data_: the data validated by the keyword (added with `verbose` option).1350 1351 __Please note__: `propertyNames` keyword schema validation errors have an additional property `propertyName`, `dataPath` points to the object. After schema validation for each property name, if it is invalid an additional error is added with the property `keyword` equal to `"propertyNames"`.1352 1353 1354 ### Error parameters1355 1356 Properties of `params` object in errors depend on the keyword that failed validation.1357 1358 - `maxItems`, `minItems`, `maxLength`, `minLength`, `maxProperties`, `minProperties` - property `limit` (number, the schema of the keyword).1359 - `additionalItems` - property `limit` (the maximum number of allowed items in case when `items` keyword is an array of schemas and `additionalItems` is false).1360 - `additionalProperties` - property `additionalProperty` (the property not used in `properties` and `patternProperties` keywords).1361 - `dependencies` - properties:1362 - `property` (dependent property),1363 - `missingProperty` (required missing dependency - only the first one is reported currently)1364 - `deps` (required dependencies, comma separated list as a string),1365 - `depsCount` (the number of required dependencies).1366 - `format` - property `format` (the schema of the keyword).1367 - `maximum`, `minimum` - properties:1368 - `limit` (number, the schema of the keyword),1369 - `exclusive` (boolean, the schema of `exclusiveMaximum` or `exclusiveMinimum`),1370 - `comparison` (string, comparison operation to compare the data to the limit, with the data on the left and the limit on the right; can be "<", "<=", ">", ">=")1371 - `multipleOf` - property `multipleOf` (the schema of the keyword)1372 - `pattern` - property `pattern` (the schema of the keyword)1373 - `required` - property `missingProperty` (required property that is missing).1374 - `propertyNames` - property `propertyName` (an invalid property name).1375 - `patternRequired` (in ajv-keywords) - property `missingPattern` (required pattern that did not match any property).1376 - `type` - property `type` (required type(s), a string, can be a comma-separated list)1377 - `uniqueItems` - properties `i` and `j` (indices of duplicate items).1378 - `const` - property `allowedValue` pointing to the value (the schema of the keyword).1379 - `enum` - property `allowedValues` pointing to the array of values (the schema of the keyword).1380 - `$ref` - property `ref` with the referenced schema URI.1381 - `oneOf` - property `passingSchemas` (array of indices of passing schemas, null if no schema passes).1382 - custom keywords (in case keyword definition doesn't create errors) - property `keyword` (the keyword name).1383 1384 1385 ### Error logging1386 1387 Using the `logger` option when initiallizing Ajv will allow you to define custom logging. Here you can build upon the exisiting logging. The use of other logging packages is supported as long as the package or its associated wrapper exposes the required methods. If any of the required methods are missing an exception will be thrown.1388 - **Required Methods**: `log`, `warn`, `error`1389 1390 ```javascript1391 var otherLogger = new OtherLogger();1392 var ajv = new Ajv({1393 logger: {1394 log: console.log.bind(console),1395 warn: function warn() {1396 otherLogger.logWarn.apply(otherLogger, arguments);1397 },1398 error: function error() {1399 otherLogger.logError.apply(otherLogger, arguments);1400 console.error.apply(console, arguments);1401 }1402 }1403 });1404 ```1405 1406 1407 ## Plugins1408 1409 Ajv can be extended with plugins that add custom keywords, formats or functions to process generated code. When such plugin is published as npm package it is recommended that it follows these conventions:1410 1411 - it exports a function1412 - this function accepts ajv instance as the first parameter and returns the same instance to allow chaining1413 - this function can accept an optional configuration as the second parameter1414 1415 If you have published a useful plugin please submit a PR to add it to the next section.1416 1417 1418 ## Related packages1419 1420 - [ajv-async](https://github.com/ajv-validator/ajv-async) - plugin to configure async validation mode1421 - [ajv-bsontype](https://github.com/BoLaMN/ajv-bsontype) - plugin to validate mongodb's bsonType formats1422 - [ajv-cli](https://github.com/jessedc/ajv-cli) - command line interface1423 - [ajv-errors](https://github.com/ajv-validator/ajv-errors) - plugin for custom error messages1424 - [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) - internationalised error messages1425 - [ajv-istanbul](https://github.com/ajv-validator/ajv-istanbul) - plugin to instrument generated validation code to measure test coverage of your schemas1426 - [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 $patch1428 - [ajv-pack](https://github.com/ajv-validator/ajv-pack) - produces a compact module exporting validation functions1429 - [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`).1430 1431 ## Some packages using Ajv1432 1433 - [webpack](https://github.com/webpack/webpack) - a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser1434 - [jsonscript-js](https://github.com/JSONScript/jsonscript-js) - the interpreter for [JSONScript](http://www.jsonscript.org) - scripted processing of existing endpoints and services1435 - [osprey-method-handler](https://github.com/mulesoft-labs/osprey-method-handler) - Express middleware for validating requests and responses based on a RAML method object, used in [osprey](https://github.com/mulesoft/osprey) - validating API proxy generated from a RAML definition1436 - [har-validator](https://github.com/ahmadnassri/har-validator) - HTTP Archive (HAR) validator1437 - [jsoneditor](https://github.com/josdejong/jsoneditor) - a web-based tool to view, edit, format, and validate JSON http://jsoneditoronline.org1438 - [JSON Schema Lint](https://github.com/nickcmaynard/jsonschemalint) - a web tool to validate JSON/YAML document against a single JSON Schema http://jsonschemalint.com1439 - [objection](https://github.com/vincit/objection.js) - SQL-friendly ORM for Node.js1440 - [table](https://github.com/gajus/table) - formats data into a string table1441 - [ripple-lib](https://github.com/ripple/ripple-lib) - a JavaScript API for interacting with [Ripple](https://ripple.com) in Node.js and the browser1442 - [restbase](https://github.com/wikimedia/restbase) - distributed storage with REST API & dispatcher for backend services built to provide a low-latency & high-throughput API for Wikipedia / Wikimedia content1443 - [hippie-swagger](https://github.com/CacheControl/hippie-swagger) - [Hippie](https://github.com/vesln/hippie) wrapper that provides end to end API testing with swagger validation1444 - [react-form-controlled](https://github.com/seeden/react-form-controlled) - React controlled form components with validation1445 - [rabbitmq-schema](https://github.com/tjmehta/rabbitmq-schema) - a schema definition module for RabbitMQ graphs and messages1446 - [@query/schema](https://www.npmjs.com/package/@query/schema) - stream filtering with a URI-safe query syntax parsing to JSON Schema1447 - [chai-ajv-json-schema](https://github.com/peon374/chai-ajv-json-schema) - chai plugin to us JSON Schema with expect in mocha tests1448 - [grunt-jsonschema-ajv](https://github.com/SignpostMarv/grunt-jsonschema-ajv) - Grunt plugin for validating files against JSON Schema1449 - [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) - extract text from bundle into a file1450 - [electron-builder](https://github.com/electron-userland/electron-builder) - a solution to package and build a ready for distribution Electron app1451 - [addons-linter](https://github.com/mozilla/addons-linter) - Mozilla Add-ons Linter1452 - [gh-pages-generator](https://github.com/epoberezkin/gh-pages-generator) - multi-page site generator converting markdown files to GitHub pages1453 - [ESLint](https://github.com/eslint/eslint) - the pluggable linting utility for JavaScript and JSX1454 1455 1456 ## Tests1457 1458 ```1459 npm install1460 git submodule update --init1461 npm test1462 ```1463 1464 ## Contributing1465 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.1467 1468 `npm run build` - compiles templates to [dotjs](https://github.com/ajv-validator/ajv/tree/master/lib/dotjs) folder.1469 1470 `npm run watch` - automatically compiles templates when files in dot folder change1471 1472 Please see [Contributing guidelines](https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md)1473 1474 1475 ## Changes history1476 1477 See https://github.com/ajv-validator/ajv/releases1478 1479 __Please note__: [Changes in version 7.0.0-beta](https://github.com/ajv-validator/ajv/releases/tag/v7.0.0-beta.0)1480 1481 [Version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0).1482 1483 ## Code of conduct1484 1485 Please review and follow the [Code of conduct](https://github.com/ajv-validator/ajv/blob/master/CODE_OF_CONDUCT.md).1486 1487 Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team.1488 1489 1490 201 ## Open-source software support 1491 202 1492 203 Ajv is a part of [Tidelift subscription](https://tidelift.com/subscription/pkg/npm-ajv?utm_source=npm-ajv&utm_medium=referral&utm_campaign=readme) - it provides a centralised support to open-source software users, in addition to the support provided by software maintainers. 1493 204 1494 1495 205 ## License 1496 206 1497 [MIT]( https://github.com/ajv-validator/ajv/blob/master/LICENSE)207 [MIT](./LICENSE) -
imaps-frontend/node_modules/ajv/lib/refs/data.json
r0c6b92a r79a0317 1 1 { 2 "$schema": "http://json-schema.org/draft-07/schema#", 3 "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#", 4 "description": "Meta-schema for $data reference (JSON Schema extension proposal)", 5 "type": "object", 6 "required": [ "$data" ], 7 "properties": { 8 "$data": { 9 "type": "string", 10 "anyOf": [ 11 { "format": "relative-json-pointer" }, 12 { "format": "json-pointer" } 13 ] 14 } 15 }, 16 "additionalProperties": false 2 "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#", 3 "description": "Meta-schema for $data reference (JSON AnySchema extension proposal)", 4 "type": "object", 5 "required": ["$data"], 6 "properties": { 7 "$data": { 8 "type": "string", 9 "anyOf": [{"format": "relative-json-pointer"}, {"format": "json-pointer"}] 10 } 11 }, 12 "additionalProperties": false 17 13 } -
imaps-frontend/node_modules/ajv/lib/refs/json-schema-draft-06.json
r0c6b92a r79a0317 1 1 { 2 "$schema": "http://json-schema.org/draft-06/schema#", 3 "$id": "http://json-schema.org/draft-06/schema#", 4 "title": "Core schema meta-schema", 2 "$schema": "http://json-schema.org/draft-06/schema#", 3 "$id": "http://json-schema.org/draft-06/schema#", 4 "title": "Core schema meta-schema", 5 "definitions": { 6 "schemaArray": { 7 "type": "array", 8 "minItems": 1, 9 "items": {"$ref": "#"} 10 }, 11 "nonNegativeInteger": { 12 "type": "integer", 13 "minimum": 0 14 }, 15 "nonNegativeIntegerDefault0": { 16 "allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}] 17 }, 18 "simpleTypes": { 19 "enum": ["array", "boolean", "integer", "null", "number", "object", "string"] 20 }, 21 "stringArray": { 22 "type": "array", 23 "items": {"type": "string"}, 24 "uniqueItems": true, 25 "default": [] 26 } 27 }, 28 "type": ["object", "boolean"], 29 "properties": { 30 "$id": { 31 "type": "string", 32 "format": "uri-reference" 33 }, 34 "$schema": { 35 "type": "string", 36 "format": "uri" 37 }, 38 "$ref": { 39 "type": "string", 40 "format": "uri-reference" 41 }, 42 "title": { 43 "type": "string" 44 }, 45 "description": { 46 "type": "string" 47 }, 48 "default": {}, 49 "examples": { 50 "type": "array", 51 "items": {} 52 }, 53 "multipleOf": { 54 "type": "number", 55 "exclusiveMinimum": 0 56 }, 57 "maximum": { 58 "type": "number" 59 }, 60 "exclusiveMaximum": { 61 "type": "number" 62 }, 63 "minimum": { 64 "type": "number" 65 }, 66 "exclusiveMinimum": { 67 "type": "number" 68 }, 69 "maxLength": {"$ref": "#/definitions/nonNegativeInteger"}, 70 "minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, 71 "pattern": { 72 "type": "string", 73 "format": "regex" 74 }, 75 "additionalItems": {"$ref": "#"}, 76 "items": { 77 "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}], 78 "default": {} 79 }, 80 "maxItems": {"$ref": "#/definitions/nonNegativeInteger"}, 81 "minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, 82 "uniqueItems": { 83 "type": "boolean", 84 "default": false 85 }, 86 "contains": {"$ref": "#"}, 87 "maxProperties": {"$ref": "#/definitions/nonNegativeInteger"}, 88 "minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, 89 "required": {"$ref": "#/definitions/stringArray"}, 90 "additionalProperties": {"$ref": "#"}, 5 91 "definitions": { 6 "schemaArray": { 7 "type": "array", 8 "minItems": 1, 9 "items": { "$ref": "#" } 10 }, 11 "nonNegativeInteger": { 12 "type": "integer", 13 "minimum": 0 14 }, 15 "nonNegativeIntegerDefault0": { 16 "allOf": [ 17 { "$ref": "#/definitions/nonNegativeInteger" }, 18 { "default": 0 } 19 ] 20 }, 21 "simpleTypes": { 22 "enum": [ 23 "array", 24 "boolean", 25 "integer", 26 "null", 27 "number", 28 "object", 29 "string" 30 ] 31 }, 32 "stringArray": { 33 "type": "array", 34 "items": { "type": "string" }, 35 "uniqueItems": true, 36 "default": [] 92 "type": "object", 93 "additionalProperties": {"$ref": "#"}, 94 "default": {} 95 }, 96 "properties": { 97 "type": "object", 98 "additionalProperties": {"$ref": "#"}, 99 "default": {} 100 }, 101 "patternProperties": { 102 "type": "object", 103 "additionalProperties": {"$ref": "#"}, 104 "default": {} 105 }, 106 "dependencies": { 107 "type": "object", 108 "additionalProperties": { 109 "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}] 110 } 111 }, 112 "propertyNames": {"$ref": "#"}, 113 "const": {}, 114 "enum": { 115 "type": "array", 116 "minItems": 1, 117 "uniqueItems": true 118 }, 119 "type": { 120 "anyOf": [ 121 {"$ref": "#/definitions/simpleTypes"}, 122 { 123 "type": "array", 124 "items": {"$ref": "#/definitions/simpleTypes"}, 125 "minItems": 1, 126 "uniqueItems": true 37 127 } 128 ] 38 129 }, 39 "type": ["object", "boolean"], 40 "properties": { 41 "$id": { 42 "type": "string", 43 "format": "uri-reference" 44 }, 45 "$schema": { 46 "type": "string", 47 "format": "uri" 48 }, 49 "$ref": { 50 "type": "string", 51 "format": "uri-reference" 52 }, 53 "title": { 54 "type": "string" 55 }, 56 "description": { 57 "type": "string" 58 }, 59 "default": {}, 60 "examples": { 61 "type": "array", 62 "items": {} 63 }, 64 "multipleOf": { 65 "type": "number", 66 "exclusiveMinimum": 0 67 }, 68 "maximum": { 69 "type": "number" 70 }, 71 "exclusiveMaximum": { 72 "type": "number" 73 }, 74 "minimum": { 75 "type": "number" 76 }, 77 "exclusiveMinimum": { 78 "type": "number" 79 }, 80 "maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, 81 "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, 82 "pattern": { 83 "type": "string", 84 "format": "regex" 85 }, 86 "additionalItems": { "$ref": "#" }, 87 "items": { 88 "anyOf": [ 89 { "$ref": "#" }, 90 { "$ref": "#/definitions/schemaArray" } 91 ], 92 "default": {} 93 }, 94 "maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, 95 "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, 96 "uniqueItems": { 97 "type": "boolean", 98 "default": false 99 }, 100 "contains": { "$ref": "#" }, 101 "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, 102 "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, 103 "required": { "$ref": "#/definitions/stringArray" }, 104 "additionalProperties": { "$ref": "#" }, 105 "definitions": { 106 "type": "object", 107 "additionalProperties": { "$ref": "#" }, 108 "default": {} 109 }, 110 "properties": { 111 "type": "object", 112 "additionalProperties": { "$ref": "#" }, 113 "default": {} 114 }, 115 "patternProperties": { 116 "type": "object", 117 "additionalProperties": { "$ref": "#" }, 118 "default": {} 119 }, 120 "dependencies": { 121 "type": "object", 122 "additionalProperties": { 123 "anyOf": [ 124 { "$ref": "#" }, 125 { "$ref": "#/definitions/stringArray" } 126 ] 127 } 128 }, 129 "propertyNames": { "$ref": "#" }, 130 "const": {}, 131 "enum": { 132 "type": "array", 133 "minItems": 1, 134 "uniqueItems": true 135 }, 136 "type": { 137 "anyOf": [ 138 { "$ref": "#/definitions/simpleTypes" }, 139 { 140 "type": "array", 141 "items": { "$ref": "#/definitions/simpleTypes" }, 142 "minItems": 1, 143 "uniqueItems": true 144 } 145 ] 146 }, 147 "format": { "type": "string" }, 148 "allOf": { "$ref": "#/definitions/schemaArray" }, 149 "anyOf": { "$ref": "#/definitions/schemaArray" }, 150 "oneOf": { "$ref": "#/definitions/schemaArray" }, 151 "not": { "$ref": "#" } 152 }, 153 "default": {} 130 "format": {"type": "string"}, 131 "allOf": {"$ref": "#/definitions/schemaArray"}, 132 "anyOf": {"$ref": "#/definitions/schemaArray"}, 133 "oneOf": {"$ref": "#/definitions/schemaArray"}, 134 "not": {"$ref": "#"} 135 }, 136 "default": {} 154 137 } -
imaps-frontend/node_modules/ajv/lib/refs/json-schema-draft-07.json
r0c6b92a r79a0317 1 1 { 2 "$schema": "http://json-schema.org/draft-07/schema#", 3 "$id": "http://json-schema.org/draft-07/schema#", 4 "title": "Core schema meta-schema", 2 "$schema": "http://json-schema.org/draft-07/schema#", 3 "$id": "http://json-schema.org/draft-07/schema#", 4 "title": "Core schema meta-schema", 5 "definitions": { 6 "schemaArray": { 7 "type": "array", 8 "minItems": 1, 9 "items": {"$ref": "#"} 10 }, 11 "nonNegativeInteger": { 12 "type": "integer", 13 "minimum": 0 14 }, 15 "nonNegativeIntegerDefault0": { 16 "allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}] 17 }, 18 "simpleTypes": { 19 "enum": ["array", "boolean", "integer", "null", "number", "object", "string"] 20 }, 21 "stringArray": { 22 "type": "array", 23 "items": {"type": "string"}, 24 "uniqueItems": true, 25 "default": [] 26 } 27 }, 28 "type": ["object", "boolean"], 29 "properties": { 30 "$id": { 31 "type": "string", 32 "format": "uri-reference" 33 }, 34 "$schema": { 35 "type": "string", 36 "format": "uri" 37 }, 38 "$ref": { 39 "type": "string", 40 "format": "uri-reference" 41 }, 42 "$comment": { 43 "type": "string" 44 }, 45 "title": { 46 "type": "string" 47 }, 48 "description": { 49 "type": "string" 50 }, 51 "default": true, 52 "readOnly": { 53 "type": "boolean", 54 "default": false 55 }, 56 "examples": { 57 "type": "array", 58 "items": true 59 }, 60 "multipleOf": { 61 "type": "number", 62 "exclusiveMinimum": 0 63 }, 64 "maximum": { 65 "type": "number" 66 }, 67 "exclusiveMaximum": { 68 "type": "number" 69 }, 70 "minimum": { 71 "type": "number" 72 }, 73 "exclusiveMinimum": { 74 "type": "number" 75 }, 76 "maxLength": {"$ref": "#/definitions/nonNegativeInteger"}, 77 "minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, 78 "pattern": { 79 "type": "string", 80 "format": "regex" 81 }, 82 "additionalItems": {"$ref": "#"}, 83 "items": { 84 "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}], 85 "default": true 86 }, 87 "maxItems": {"$ref": "#/definitions/nonNegativeInteger"}, 88 "minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, 89 "uniqueItems": { 90 "type": "boolean", 91 "default": false 92 }, 93 "contains": {"$ref": "#"}, 94 "maxProperties": {"$ref": "#/definitions/nonNegativeInteger"}, 95 "minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, 96 "required": {"$ref": "#/definitions/stringArray"}, 97 "additionalProperties": {"$ref": "#"}, 5 98 "definitions": { 6 "schemaArray": { 7 "type": "array", 8 "minItems": 1, 9 "items": { "$ref": "#" } 10 }, 11 "nonNegativeInteger": { 12 "type": "integer", 13 "minimum": 0 14 }, 15 "nonNegativeIntegerDefault0": { 16 "allOf": [ 17 { "$ref": "#/definitions/nonNegativeInteger" }, 18 { "default": 0 } 19 ] 20 }, 21 "simpleTypes": { 22 "enum": [ 23 "array", 24 "boolean", 25 "integer", 26 "null", 27 "number", 28 "object", 29 "string" 30 ] 31 }, 32 "stringArray": { 33 "type": "array", 34 "items": { "type": "string" }, 35 "uniqueItems": true, 36 "default": [] 99 "type": "object", 100 "additionalProperties": {"$ref": "#"}, 101 "default": {} 102 }, 103 "properties": { 104 "type": "object", 105 "additionalProperties": {"$ref": "#"}, 106 "default": {} 107 }, 108 "patternProperties": { 109 "type": "object", 110 "additionalProperties": {"$ref": "#"}, 111 "propertyNames": {"format": "regex"}, 112 "default": {} 113 }, 114 "dependencies": { 115 "type": "object", 116 "additionalProperties": { 117 "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}] 118 } 119 }, 120 "propertyNames": {"$ref": "#"}, 121 "const": true, 122 "enum": { 123 "type": "array", 124 "items": true, 125 "minItems": 1, 126 "uniqueItems": true 127 }, 128 "type": { 129 "anyOf": [ 130 {"$ref": "#/definitions/simpleTypes"}, 131 { 132 "type": "array", 133 "items": {"$ref": "#/definitions/simpleTypes"}, 134 "minItems": 1, 135 "uniqueItems": true 37 136 } 137 ] 38 138 }, 39 "type": ["object", "boolean"], 40 "properties": { 41 "$id": { 42 "type": "string", 43 "format": "uri-reference" 44 }, 45 "$schema": { 46 "type": "string", 47 "format": "uri" 48 }, 49 "$ref": { 50 "type": "string", 51 "format": "uri-reference" 52 }, 53 "$comment": { 54 "type": "string" 55 }, 56 "title": { 57 "type": "string" 58 }, 59 "description": { 60 "type": "string" 61 }, 62 "default": true, 63 "readOnly": { 64 "type": "boolean", 65 "default": false 66 }, 67 "examples": { 68 "type": "array", 69 "items": true 70 }, 71 "multipleOf": { 72 "type": "number", 73 "exclusiveMinimum": 0 74 }, 75 "maximum": { 76 "type": "number" 77 }, 78 "exclusiveMaximum": { 79 "type": "number" 80 }, 81 "minimum": { 82 "type": "number" 83 }, 84 "exclusiveMinimum": { 85 "type": "number" 86 }, 87 "maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, 88 "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, 89 "pattern": { 90 "type": "string", 91 "format": "regex" 92 }, 93 "additionalItems": { "$ref": "#" }, 94 "items": { 95 "anyOf": [ 96 { "$ref": "#" }, 97 { "$ref": "#/definitions/schemaArray" } 98 ], 99 "default": true 100 }, 101 "maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, 102 "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, 103 "uniqueItems": { 104 "type": "boolean", 105 "default": false 106 }, 107 "contains": { "$ref": "#" }, 108 "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, 109 "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, 110 "required": { "$ref": "#/definitions/stringArray" }, 111 "additionalProperties": { "$ref": "#" }, 112 "definitions": { 113 "type": "object", 114 "additionalProperties": { "$ref": "#" }, 115 "default": {} 116 }, 117 "properties": { 118 "type": "object", 119 "additionalProperties": { "$ref": "#" }, 120 "default": {} 121 }, 122 "patternProperties": { 123 "type": "object", 124 "additionalProperties": { "$ref": "#" }, 125 "propertyNames": { "format": "regex" }, 126 "default": {} 127 }, 128 "dependencies": { 129 "type": "object", 130 "additionalProperties": { 131 "anyOf": [ 132 { "$ref": "#" }, 133 { "$ref": "#/definitions/stringArray" } 134 ] 135 } 136 }, 137 "propertyNames": { "$ref": "#" }, 138 "const": true, 139 "enum": { 140 "type": "array", 141 "items": true, 142 "minItems": 1, 143 "uniqueItems": true 144 }, 145 "type": { 146 "anyOf": [ 147 { "$ref": "#/definitions/simpleTypes" }, 148 { 149 "type": "array", 150 "items": { "$ref": "#/definitions/simpleTypes" }, 151 "minItems": 1, 152 "uniqueItems": true 153 } 154 ] 155 }, 156 "format": { "type": "string" }, 157 "contentMediaType": { "type": "string" }, 158 "contentEncoding": { "type": "string" }, 159 "if": {"$ref": "#"}, 160 "then": {"$ref": "#"}, 161 "else": {"$ref": "#"}, 162 "allOf": { "$ref": "#/definitions/schemaArray" }, 163 "anyOf": { "$ref": "#/definitions/schemaArray" }, 164 "oneOf": { "$ref": "#/definitions/schemaArray" }, 165 "not": { "$ref": "#" } 166 }, 167 "default": true 139 "format": {"type": "string"}, 140 "contentMediaType": {"type": "string"}, 141 "contentEncoding": {"type": "string"}, 142 "if": {"$ref": "#"}, 143 "then": {"$ref": "#"}, 144 "else": {"$ref": "#"}, 145 "allOf": {"$ref": "#/definitions/schemaArray"}, 146 "anyOf": {"$ref": "#/definitions/schemaArray"}, 147 "oneOf": {"$ref": "#/definitions/schemaArray"}, 148 "not": {"$ref": "#"} 149 }, 150 "default": true 168 151 } -
imaps-frontend/node_modules/ajv/lib/refs/json-schema-secure.json
r0c6b92a r79a0317 3 3 "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/json-schema-secure.json#", 4 4 "title": "Meta-schema for the security assessment of JSON Schemas", 5 "description": "If a JSON Schema fails validation against this meta-schema, it may be unsafe to validate untrusted data",5 "description": "If a JSON AnySchema fails validation against this meta-schema, it may be unsafe to validate untrusted data", 6 6 "definitions": { 7 7 "schemaArray": { … … 61 61 "dependencies": { 62 62 "additionalProperties": { 63 "anyOf": [ 64 {"type": "array"}, 65 {"$ref": "#"} 66 ] 63 "anyOf": [{"type": "array"}, {"$ref": "#"}] 67 64 } 68 65 }, 69 66 "items": { 70 "anyOf": [ 71 {"$ref": "#"}, 72 {"$ref": "#/definitions/schemaArray"} 73 ] 67 "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}] 74 68 }, 75 69 "definitions": { -
imaps-frontend/node_modules/ajv/package.json
r0c6b92a r79a0317 1 1 { 2 2 "name": "ajv", 3 "version": " 6.12.6",3 "version": "8.17.1", 4 4 "description": "Another JSON Schema Validator", 5 "main": " lib/ajv.js",6 "typ ings": "lib/ajv.d.ts",5 "main": "dist/ajv.js", 6 "types": "dist/ajv.d.ts", 7 7 "files": [ 8 8 "lib/", 9 9 "dist/", 10 "scripts/", 11 "LICENSE", 12 ".tonic_example.js" 10 ".runkit_example.js" 13 11 ], 14 12 "scripts": { 15 "eslint": "eslint lib/{compile/,}*.js spec/{**/,}*.js scripts--ignore-pattern spec/JSON-Schema-Test-Suite",16 " jshint": "jshint lib/{compile/,}*.js",17 " lint": "npm run jshint && npm run eslint",18 "test-spec": " mocha spec/{**/,}*.spec.js -R spec",19 "test- fast": "AJV_FAST_TEST=true npm run test-spec",13 "eslint": "eslint \"lib/**/*.ts\" \"spec/**/*.*s\" --ignore-pattern spec/JSON-Schema-Test-Suite", 14 "prettier:write": "prettier --write \"./**/*.{json,yaml,js,ts}\"", 15 "prettier:check": "prettier --list-different \"./**/*.{json,yaml,js,ts}\"", 16 "test-spec": "cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register \"spec/**/*.spec.{ts,js}\" -R dot", 17 "test-codegen": "nyc cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register 'spec/codegen.spec.ts' -R spec", 20 18 "test-debug": "npm run test-spec -- --inspect-brk", 21 19 "test-cov": "nyc npm run test-spec", 22 " test-ts": "tsc --target ES5 --noImplicitAny --noEmit spec/typescript/index.ts",23 "bundle": " del-cli dist && node ./scripts/bundle.js . Ajv pure_getters",24 "bu ndle-beautify": "node ./scripts/bundle.js js-beautify",25 " build": "del-cli lib/dotjs/*.js \"!lib/dotjs/index.js\" && node scripts/compile-dots.js",20 "rollup": "rm -rf bundle && rollup -c", 21 "bundle": "rm -rf bundle && node ./scripts/bundle.js ajv ajv7 ajv7 && node ./scripts/bundle.js 2019 ajv2019 ajv2019 && node ./scripts/bundle.js 2020 ajv2020 ajv2020 && node ./scripts/bundle.js jtd ajvJTD ajvJTD", 22 "build": "rm -rf dist && tsc && cp -r lib/refs dist && rm dist/refs/json-schema-2019-09/index.ts && rm dist/refs/json-schema-2020-12/index.ts && rm dist/refs/jtd-schema.ts", 23 "json-tests": "rm -rf spec/_json/*.js && node scripts/jsontests", 26 24 "test-karma": "karma start", 27 "test-browser": "del-cli .browser && npm run bundle && scripts/prepare-tests && npm run test-karma", 28 "test-all": "npm run test-cov && if-node-version 10 npm run test-browser", 29 "test": "npm run lint && npm run build && npm run test-all", 30 "prepublish": "npm run build && npm run bundle", 31 "watch": "watch \"npm run build\" ./lib/dot" 25 "test-browser": "rm -rf .browser && npm run bundle && scripts/prepare-tests && karma start", 26 "test-all": "npm run test-cov && if-node-version 12 npm run test-browser", 27 "test": "npm run json-tests && npm run prettier:check && npm run eslint && npm link && npm link --legacy-peer-deps ajv && npm run test-cov", 28 "test-ci": "AJV_FULL_TEST=true npm test", 29 "prepublish": "npm run build", 30 "benchmark": "npm i && npm run build && npm link && cd ./benchmark && npm link --legacy-peer-deps ajv && npm i && node ./jtd", 31 "docs:dev": "./scripts/prepare-site && vuepress dev docs", 32 "docs:build": "./scripts/prepare-site && vuepress build docs" 32 33 }, 33 34 "nyc": { … … 41 42 ] 42 43 }, 43 "repository": { 44 "type": "git", 45 "url": "https://github.com/ajv-validator/ajv.git" 46 }, 44 "repository": "ajv-validator/ajv", 47 45 "keywords": [ 48 46 "JSON", … … 57 55 "author": "Evgeny Poberezkin", 58 56 "license": "MIT", 59 "bugs": { 60 "url": "https://github.com/ajv-validator/ajv/issues" 61 }, 62 "homepage": "https://github.com/ajv-validator/ajv", 63 "tonicExampleFilename": ".tonic_example.js", 57 "bugs": "https://github.com/ajv-validator/ajv/issues", 58 "homepage": "https://ajv.js.org", 59 "runkitExampleFilename": ".runkit_example.js", 64 60 "dependencies": { 65 "fast-deep-equal": "^3.1. 1",66 "fast- json-stable-stringify": "^2.0.0",67 "json-schema-traverse": "^ 0.4.1",68 " uri-js": "^4.2.2"61 "fast-deep-equal": "^3.1.3", 62 "fast-uri": "^3.0.1", 63 "json-schema-traverse": "^1.0.0", 64 "require-from-string": "^2.0.2" 69 65 }, 70 66 "devDependencies": { 71 "ajv-async": "^1.0.0", 72 "bluebird": "^3.5.3", 73 "brfs": "^2.0.0", 74 "browserify": "^16.2.0", 75 "chai": "^4.0.1", 76 "coveralls": "^3.0.1", 77 "del-cli": "^3.0.0", 78 "dot": "^1.0.3", 79 "eslint": "^7.3.1", 80 "gh-pages-generator": "^0.2.3", 81 "glob": "^7.0.0", 82 "if-node-version": "^1.0.0", 83 "js-beautify": "^1.7.3", 84 "jshint": "^2.10.2", 67 "@ajv-validator/config": "^0.5.0", 68 "@rollup/plugin-commonjs": "^25.0.7", 69 "@rollup/plugin-json": "^6.1.0", 70 "@rollup/plugin-node-resolve": "^15.2.3", 71 "@rollup/plugin-typescript": "^11.1.6", 72 "@types/chai": "^4.3.11", 73 "@types/mocha": "^10.0.6", 74 "@types/node": "^20.11.30", 75 "@types/require-from-string": "^1.2.3", 76 "@typescript-eslint/eslint-plugin": "^7.3.1", 77 "@typescript-eslint/parser": "^7.3.1", 78 "ajv-formats": "^3.0.1", 79 "browserify": "^17.0.0", 80 "chai": "^4.4.1", 81 "cross-env": "^7.0.3", 82 "dayjs": "^1.11.10", 83 "dayjs-plugin-utc": "^0.1.2", 84 "eslint": "^8.57.0", 85 "eslint-config-prettier": "^9.1.0", 86 "glob": "^10.3.10", 87 "husky": "^9.0.11", 88 "if-node-version": "^1.1.1", 89 "jimp": "^0.22.10", 90 "js-beautify": "^1.15.1", 85 91 "json-schema-test": "^2.0.0", 86 "karma": "^5.0.0", 87 "karma-chrome-launcher": "^3.0.0", 88 "karma-mocha": "^2.0.0", 89 "karma-sauce-launcher": "^4.1.3", 90 "mocha": "^8.0.1", 91 "nyc": "^15.0.0", 92 "pre-commit": "^1.1.1", 93 "require-globify": "^1.3.0", 94 "typescript": "^3.9.5", 95 "uglify-js": "^3.6.9", 96 "watch": "^1.0.0" 92 "karma": "^6.4.2", 93 "karma-chrome-launcher": "^3.2.0", 94 "karma-mocha": "^2.0.1", 95 "lint-staged": "^15.2.2", 96 "mocha": "^10.3.0", 97 "module-from-string": "^3.3.0", 98 "node-fetch": "^3.3.2", 99 "nyc": "^15.1.0", 100 "prettier": "3.0.3", 101 "re2": "^1.20.9", 102 "rollup": "^2.79.1", 103 "rollup-plugin-terser": "^7.0.2", 104 "ts-node": "^10.9.2", 105 "tsify": "^5.0.4", 106 "typescript": "5.3.3", 107 "uri-js": "^4.4.1" 97 108 }, 98 109 "collective": { … … 103 114 "type": "github", 104 115 "url": "https://github.com/sponsors/epoberezkin" 116 }, 117 "prettier": "@ajv-validator/config/prettierrc.json", 118 "husky": { 119 "hooks": { 120 "pre-commit": "lint-staged && npm test" 121 } 122 }, 123 "lint-staged": { 124 "*.{json,yaml,js,ts}": "prettier --write" 105 125 } 106 126 }
Note:
See TracChangeset
for help on using the changeset viewer.