source: imaps-frontend/node_modules/ajv/README.md@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 13.5 KB
RevLine 
[79a0317]1<img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/img/ajv.svg">
[d565449]2
[79a0317]3&nbsp;
[d565449]4
[79a0317]5# Ajv JSON schema validator
[d565449]6
[79a0317]7The fastest JSON validator for Node.js and browser.
8
9Supports 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)
[d565449]12[![npm](https://img.shields.io/npm/v/ajv.svg)](https://www.npmjs.com/package/ajv)
13[![npm downloads](https://img.shields.io/npm/dm/ajv.svg)](https://www.npmjs.com/package/ajv)
14[![Coverage Status](https://coveralls.io/repos/github/ajv-validator/ajv/badge.svg?branch=master)](https://coveralls.io/github/ajv-validator/ajv?branch=master)
[79a0317]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)
[d565449]16[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
17[![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin)
18
[79a0317]19## Ajv sponsors
[d565449]20
[79a0317]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)
[d565449]22
[79a0317]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)
[d565449]24
[79a0317]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)
[d565449]26
[79a0317]27## Contributing
[d565449]28
[79a0317]29More 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.
[d565449]30
[79a0317]31Please review [Contributing guidelines](./CONTRIBUTING.md) and [Code components](https://ajv.js.org/components.html).
[d565449]32
[79a0317]33## Documentation
[d565449]34
[79a0317]35All documentation is available on the [Ajv website](https://ajv.js.org).
[d565449]36
[79a0317]37Some useful site links:
[d565449]38
[79a0317]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)
[d565449]47
[79a0317]48## <a name="sponsors"></a>Please [sponsor Ajv development](https://github.com/sponsors/epoberezkin)
[d565449]49
50Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant!
51
52Your continuing support is very important - the funds will be used to develop and maintain Ajv once the next major version is released.
53
54Please sponsor Ajv via:
[79a0317]55
[d565449]56- [GitHub sponsors page](https://github.com/sponsors/epoberezkin) (GitHub will match it)
[79a0317]57- [Ajv Open Collective](https://opencollective.com/ajv)
[d565449]58
59Thank you.
60
61#### Open Collective sponsors
62
63<a href="https://opencollective.com/ajv"><img src="https://opencollective.com/ajv/individuals.svg?width=890"></a>
64
65<a href="https://opencollective.com/ajv/organization/0/website"><img src="https://opencollective.com/ajv/organization/0/avatar.svg"></a>
66<a href="https://opencollective.com/ajv/organization/1/website"><img src="https://opencollective.com/ajv/organization/1/avatar.svg"></a>
67<a href="https://opencollective.com/ajv/organization/2/website"><img src="https://opencollective.com/ajv/organization/2/avatar.svg"></a>
68<a href="https://opencollective.com/ajv/organization/3/website"><img src="https://opencollective.com/ajv/organization/3/avatar.svg"></a>
69<a href="https://opencollective.com/ajv/organization/4/website"><img src="https://opencollective.com/ajv/organization/4/avatar.svg"></a>
70<a href="https://opencollective.com/ajv/organization/5/website"><img src="https://opencollective.com/ajv/organization/5/avatar.svg"></a>
71<a href="https://opencollective.com/ajv/organization/6/website"><img src="https://opencollective.com/ajv/organization/6/avatar.svg"></a>
72<a href="https://opencollective.com/ajv/organization/7/website"><img src="https://opencollective.com/ajv/organization/7/avatar.svg"></a>
73<a href="https://opencollective.com/ajv/organization/8/website"><img src="https://opencollective.com/ajv/organization/8/avatar.svg"></a>
74<a href="https://opencollective.com/ajv/organization/9/website"><img src="https://opencollective.com/ajv/organization/9/avatar.svg"></a>
[79a0317]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>
[d565449]90
91## Performance
92
[79a0317]93Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.
[d565449]94
95Currently Ajv is the fastest and the most standard compliant validator according to these benchmarks:
96
97- [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark) - 50% faster than the second place
98- [jsck benchmark](https://github.com/pandastrike/jsck#benchmarks) - 20-190% faster
99- [z-schema benchmark](https://rawgit.com/zaggino/z-schema/master/benchmark/results.html)
100- [themis benchmark](https://cdn.rawgit.com/playlyfe/themis/master/benchmark/results.html)
101
102Performance of different validators by [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark):
103
[79a0317]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)
[d565449]105
106## Features
107
[79a0317]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
[d565449]126- i18n error messages support with [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package
[79a0317]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
[d565449]134
135## Install
136
[79a0317]137To install version 8:
138
[d565449]139```
140npm install ajv
141```
142
143## <a name="usage"></a>Getting started
144
[79a0317]145Try it in the Node.js REPL: https://runkit.com/npm/ajv
[d565449]146
[79a0317]147In JavaScript:
[d565449]148
149```javascript
150// or ESM/TypeScript import
[79a0317]151import Ajv from "ajv"
152// Node.js require:
153const Ajv = require("ajv")
[d565449]154
[79a0317]155const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}
[d565449]156
[79a0317]157const schema = {
158 type: "object",
159 properties: {
160 foo: {type: "integer"},
161 bar: {type: "string"},
[d565449]162 },
[79a0317]163 required: ["foo"],
164 additionalProperties: false,
[d565449]165}
166
[79a0317]167const data = {
168 foo: 1,
169 bar: "abc",
[d565449]170}
171
[79a0317]172const validate = ajv.compile(schema)
173const valid = validate(data)
174if (!valid) console.log(validate.errors)
[d565449]175```
176
[79a0317]177Learn how to use Ajv and see more examples in the [Guide: getting started](https://ajv.js.org/guide/getting-started.html)
[d565449]178
[79a0317]179## Changes history
[d565449]180
[79a0317]181See [https://github.com/ajv-validator/ajv/releases](https://github.com/ajv-validator/ajv/releases)
[d565449]182
[79a0317]183**Please note**: [Changes in version 8.0.0](https://github.com/ajv-validator/ajv/releases/tag/v8.0.0)
[d565449]184
[79a0317]185[Version 7.0.0](https://github.com/ajv-validator/ajv/releases/tag/v7.0.0)
[d565449]186
[79a0317]187[Version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0).
[d565449]188
[79a0317]189## Code of conduct
[d565449]190
[79a0317]191Please review and follow the [Code of conduct](./CODE_OF_CONDUCT.md).
[d565449]192
[79a0317]193Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team.
[d565449]194
[79a0317]195## Security contact
[d565449]196
197To report a security vulnerability, please use the
198[Tidelift security contact](https://tidelift.com/security).
199Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues.
200
201## Open-source software support
202
203Ajv 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.
204
205## License
206
[79a0317]207[MIT](./LICENSE)
Note: See TracBrowser for help on using the repository browser.