Upload original JAVA语言程序设计 course files (part 18)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/LICENSE+22-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/README.md+207-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/core/id.ts+10-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/core/index.ts+16-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/core/ref.ts+129-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/discriminator/index.ts+113-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/discriminator/types.ts+12-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/draft2020.ts+23-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/draft7.ts+17-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/dynamicAnchor.ts+31-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/dynamicRef.ts+51-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/index.ts+9-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/recursiveAnchor.ts+14-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/recursiveRef.ts+10-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/errors.ts+18-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/format/format.ts+120-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/format/index.ts+6-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts+89-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/elements.ts+32-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/enum.ts+45-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/error.ts+23-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/index.ts+37-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/metadata.ts+24-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/nullable.ts+21-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts+15-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/properties.ts+184-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/ref.ts+76-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/type.ts+75-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/union.ts+12-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/values.ts+58-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/metadata.ts+17-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/next.ts+8-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/unevaluated/index.ts+7-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts+47-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts+85-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/const.ts+28-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/dependentRequired.ts+23-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/enum.ts+54-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/index.ts+49-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitContains.ts+16-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitItems.ts+26-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitLength.ts+30-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitNumber.ts+42-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts+26-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/multipleOf.ts+34-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/pattern.ts+28-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/required.ts+98-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/uniqueItems.ts+79-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/package.json+126-3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/anymatch/LICENSE+15-3
12312345678910111213141516171819202122version https://git-lfs.github.com/spec/v1oid sha256:a05350a88e318e4f5f2c2a1ff1e2e88daa4dd38e6e78b71cccae422bdc762cc3size 1090The MIT License (MIT)
Copyright (c) 2015-2021 Evgeny Poberezkin
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207version https://git-lfs.github.com/spec/v1oid sha256:57d9f5c9d12d019ee1c42fcd7be6a1c5b2944608b011714146ecdd20972374edsize 13781<img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/img/ajv.svg">
# Ajv JSON schema validator
The fastest JSON validator for Node.js and browser.
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/).
[](https://github.com/ajv-validator/ajv/actions?query=workflow%3Abuild)[](https://www.npmjs.com/package/ajv)[](https://www.npmjs.com/package/ajv)[](https://coveralls.io/github/ajv-validator/ajv?branch=master)[](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)[](https://gitter.im/ajv-validator/ajv)[](https://github.com/sponsors/epoberezkin)
## Ajv sponsors
[<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)
[<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)
[<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)
## Contributing
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.
Please review [Contributing guidelines](./CONTRIBUTING.md) and [Code components](https://ajv.js.org/components.html).
## Documentation
All documentation is available on the [Ajv website](https://ajv.js.org).
Some useful site links:
- [Getting started](https://ajv.js.org/guide/getting-started.html)- [JSON Schema vs JSON Type Definition](https://ajv.js.org/guide/schema-language.html)- [API reference](https://ajv.js.org/api.html)- [Strict mode](https://ajv.js.org/strict-mode.html)- [Standalone validation code](https://ajv.js.org/standalone.html)- [Security considerations](https://ajv.js.org/security.html)- [Command line interface](https://ajv.js.org/packages/ajv-cli.html)- [Frequently Asked Questions](https://ajv.js.org/faq.html)
## <a name="sponsors"></a>Please [sponsor Ajv development](https://github.com/sponsors/epoberezkin)
Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant!
Your continuing support is very important - the funds will be used to develop and maintain Ajv once the next major version is released.
Please sponsor Ajv via:
- [GitHub sponsors page](https://github.com/sponsors/epoberezkin) (GitHub will match it)- [Ajv Open Collective](https://opencollective.com/ajv)
Thank you.
#### Open Collective sponsors
<a href="https://opencollective.com/ajv"><img src="https://opencollective.com/ajv/individuals.svg?width=890"></a>
<a href="https://opencollective.com/ajv/organization/0/website"><img src="https://opencollective.com/ajv/organization/0/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/1/website"><img src="https://opencollective.com/ajv/organization/1/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/2/website"><img src="https://opencollective.com/ajv/organization/2/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/3/website"><img src="https://opencollective.com/ajv/organization/3/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/4/website"><img src="https://opencollective.com/ajv/organization/4/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/5/website"><img src="https://opencollective.com/ajv/organization/5/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/6/website"><img src="https://opencollective.com/ajv/organization/6/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/7/website"><img src="https://opencollective.com/ajv/organization/7/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/8/website"><img src="https://opencollective.com/ajv/organization/8/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/9/website"><img src="https://opencollective.com/ajv/organization/9/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/10/website"><img src="https://opencollective.com/ajv/organization/10/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/11/website"><img src="https://opencollective.com/ajv/organization/11/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/12/website"><img src="https://opencollective.com/ajv/organization/12/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/13/website"><img src="https://opencollective.com/ajv/organization/13/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/14/website"><img src="https://opencollective.com/ajv/organization/14/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/15/website"><img src="https://opencollective.com/ajv/organization/15/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/16/website"><img src="https://opencollective.com/ajv/organization/16/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/17/website"><img src="https://opencollective.com/ajv/organization/17/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/18/website"><img src="https://opencollective.com/ajv/organization/18/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/19/website"><img src="https://opencollective.com/ajv/organization/19/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/20/website"><img src="https://opencollective.com/ajv/organization/20/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/21/website"><img src="https://opencollective.com/ajv/organization/21/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/22/website"><img src="https://opencollective.com/ajv/organization/22/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/23/website"><img src="https://opencollective.com/ajv/organization/23/avatar.svg"></a><a href="https://opencollective.com/ajv/organization/24/website"><img src="https://opencollective.com/ajv/organization/24/avatar.svg"></a>
## Performance
Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.
Currently Ajv is the fastest and the most standard compliant validator according to these benchmarks:
- [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark) - 50% faster than the second place- [jsck benchmark](https://github.com/pandastrike/jsck#benchmarks) - 20-190% faster- [z-schema benchmark](https://rawgit.com/zaggino/z-schema/master/benchmark/results.html)- [themis benchmark](https://cdn.rawgit.com/playlyfe/themis/master/benchmark/results.html)
Performance of different validators by [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark):
[](https://github.com/ebdrup/json-schema-benchmark/blob/master/README.md#performance)
## Features
- Ajv implements JSON Schema [draft-06/07/2019-09/2020-12](http://json-schema.org/) standards (draft-04 is supported in v6): - all validation keywords (see [JSON Schema validation keywords](https://ajv.js.org/json-schema.html)) - [OpenAPI](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md) extensions: - NEW: keyword [discriminator](https://ajv.js.org/json-schema.html#discriminator). - keyword [nullable](https://ajv.js.org/json-schema.html#nullable). - full support of remote references (remote schemas have to be added with `addSchema` or compiled to be available) - support of recursive references between schemas - correct string lengths for strings with unicode pairs - JSON Schema [formats](https://ajv.js.org/guide/formats.html) (with [ajv-formats](https://github.com/ajv-validator/ajv-formats) plugin). - [validates schemas against meta-schema](https://ajv.js.org/api.html#api-validateschema)- NEW: supports [JSON Type Definition](https://datatracker.ietf.org/doc/rfc8927/): - all keywords (see [JSON Type Definition schema forms](https://ajv.js.org/json-type-definition.html)) - meta-schema for JTD schemas - "union" keyword and user-defined keywords (can be used inside "metadata" member of the schema)- supports [browsers](https://ajv.js.org/guide/environments.html#browsers) and Node.js 10.x - current- [asynchronous loading](https://ajv.js.org/guide/managing-schemas.html#asynchronous-schema-loading) of referenced schemas during compilation- "All errors" validation mode with [option allErrors](https://ajv.js.org/options.html#allerrors)- [error messages with parameters](https://ajv.js.org/api.html#validation-errors) describing error reasons to allow error message generation- i18n error messages support with [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package- [removing-additional-properties](https://ajv.js.org/guide/modifying-data.html#removing-additional-properties)- [assigning defaults](https://ajv.js.org/guide/modifying-data.html#assigning-defaults) to missing properties and items- [coercing data](https://ajv.js.org/guide/modifying-data.html#coercing-data-types) to the types specified in `type` keywords- [user-defined keywords](https://ajv.js.org/guide/user-keywords.html)- additional extension keywords with [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package- [\$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- [asynchronous validation](https://ajv.js.org/guide/async-validation.html) of user-defined formats and keywords
## Install
To install version 8:
```npm install ajv```
## <a name="usage"></a>Getting started
Try it in the Node.js REPL: https://runkit.com/npm/ajv
In JavaScript:
```javascript// or ESM/TypeScript importimport Ajv from "ajv"// Node.js require:const Ajv = require("ajv")
const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}
const schema = { type: "object", properties: { foo: {type: "integer"}, bar: {type: "string"}, }, required: ["foo"], additionalProperties: false,}
const data = { foo: 1, bar: "abc",}
const validate = ajv.compile(schema)const valid = validate(data)if (!valid) console.log(validate.errors)```
Learn how to use Ajv and see more examples in the [Guide: getting started](https://ajv.js.org/guide/getting-started.html)
## Changes history
See [https://github.com/ajv-validator/ajv/releases](https://github.com/ajv-validator/ajv/releases)
**Please note**: [Changes in version 8.0.0](https://github.com/ajv-validator/ajv/releases/tag/v8.0.0)
[Version 7.0.0](https://github.com/ajv-validator/ajv/releases/tag/v7.0.0)
[Version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0).
## Code of conduct
Please review and follow the [Code of conduct](./CODE_OF_CONDUCT.md).
Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team.
## Security contact
To report a security vulnerability, please use the[Tidelift security contact](https://tidelift.com/security).Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues.
## Open-source software support
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.
## License
[MIT](./LICENSE)12312345678910version https://git-lfs.github.com/spec/v1oid sha256:241606f9c18746cb35cb74c728c6d972bd6100edad70692bb27f841ac8b1b4b1size 224import type {CodeKeywordDefinition} from "../../types"
const def: CodeKeywordDefinition = { keyword: "id", code() { throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID') },}
export default def12312345678910111213141516version https://git-lfs.github.com/spec/v1oid sha256:43e089e25baac37f7665f0451e51956ec154f60a058b83f86cc3e577ab800f62size 274import type {Vocabulary} from "../../types"import idKeyword from "./id"import refKeyword from "./ref"
const core: Vocabulary = [ "$schema", "$id", "$defs", "$vocabulary", {keyword: "$comment"}, "definitions", idKeyword, refKeyword,]
export default core123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129version https://git-lfs.github.com/spec/v1oid sha256:0d932d49ef57d32449923e5687e57715f4d08252f749d34d1d9410e8f88711f8size 4384import type {CodeKeywordDefinition, AnySchema} from "../../types"import type {KeywordCxt} from "../../compile/validate"import MissingRefError from "../../compile/ref_error"import {callValidateCode} from "../code"import {_, nil, stringify, Code, Name} from "../../compile/codegen"import N from "../../compile/names"import {SchemaEnv, resolveRef} from "../../compile"import {mergeEvaluated} from "../../compile/util"
const def: CodeKeywordDefinition = { keyword: "$ref", schemaType: "string", code(cxt: KeywordCxt): void { const {gen, schema: $ref, it} = cxt const {baseId, schemaEnv: env, validateName, opts, self} = it const {root} = env if (($ref === "#" || $ref === "#/") && baseId === root.baseId) return callRootRef() const schOrEnv = resolveRef.call(self, root, baseId, $ref) if (schOrEnv === undefined) throw new MissingRefError(it.opts.uriResolver, baseId, $ref) if (schOrEnv instanceof SchemaEnv) return callValidate(schOrEnv) return inlineRefSchema(schOrEnv)
function callRootRef(): void { if (env === root) return callRef(cxt, validateName, env, env.$async) const rootName = gen.scopeValue("root", {ref: root}) return callRef(cxt, _`${rootName}.validate`, root, root.$async) }
function callValidate(sch: SchemaEnv): void { const v = getValidate(cxt, sch) callRef(cxt, v, sch, sch.$async) }
function inlineRefSchema(sch: AnySchema): void { const schName = gen.scopeValue( "schema", opts.code.source === true ? {ref: sch, code: stringify(sch)} : {ref: sch} ) const valid = gen.name("valid") const schCxt = cxt.subschema( { schema: sch, dataTypes: [], schemaPath: nil, topSchemaRef: schName, errSchemaPath: $ref, }, valid ) cxt.mergeEvaluated(schCxt) cxt.ok(valid) } },}
export function getValidate(cxt: KeywordCxt, sch: SchemaEnv): Code { const {gen} = cxt return sch.validate ? gen.scopeValue("validate", {ref: sch.validate}) : _`${gen.scopeValue("wrapper", {ref: sch})}.validate`}
export function callRef(cxt: KeywordCxt, v: Code, sch?: SchemaEnv, $async?: boolean): void { const {gen, it} = cxt const {allErrors, schemaEnv: env, opts} = it const passCxt = opts.passContext ? N.this : nil if ($async) callAsyncRef() else callSyncRef()
function callAsyncRef(): void { if (!env.$async) throw new Error("async schema referenced by sync schema") const valid = gen.let("valid") gen.try( () => { gen.code(_`await ${callValidateCode(cxt, v, passCxt)}`) addEvaluatedFrom(v) // TODO will not work with async, it has to be returned with the result if (!allErrors) gen.assign(valid, true) }, (e) => { gen.if(_`!(${e} instanceof ${it.ValidationError as Name})`, () => gen.throw(e)) addErrorsFrom(e) if (!allErrors) gen.assign(valid, false) } ) cxt.ok(valid) }
function callSyncRef(): void { cxt.result( callValidateCode(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v) ) }
function addErrorsFrom(source: Code): void { const errs = _`${source}.errors` gen.assign(N.vErrors, _`${N.vErrors} === null ? ${errs} : ${N.vErrors}.concat(${errs})`) // TODO tagged gen.assign(N.errors, _`${N.vErrors}.length`) }
function addEvaluatedFrom(source: Code): void { if (!it.opts.unevaluated) return const schEvaluated = sch?.validate?.evaluated // TODO refactor if (it.props !== true) { if (schEvaluated && !schEvaluated.dynamicProps) { if (schEvaluated.props !== undefined) { it.props = mergeEvaluated.props(gen, schEvaluated.props, it.props) } } else { const props = gen.var("props", _`${source}.evaluated.props`) it.props = mergeEvaluated.props(gen, props, it.props, Name) } } if (it.items !== true) { if (schEvaluated && !schEvaluated.dynamicItems) { if (schEvaluated.items !== undefined) { it.items = mergeEvaluated.items(gen, schEvaluated.items, it.items) } } else { const items = gen.var("items", _`${source}.evaluated.items`) it.items = mergeEvaluated.items(gen, items, it.items, Name) } } }}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113version https://git-lfs.github.com/spec/v1oid sha256:9b89f8b9ab15e49b326bb3505424a1c0cd234397bf7db13a80e74e627fc381a3size 4304import type {CodeKeywordDefinition, AnySchemaObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, getProperty, Name} from "../../compile/codegen"import {DiscrError, DiscrErrorObj} from "../discriminator/types"import {resolveRef, SchemaEnv} from "../../compile"import MissingRefError from "../../compile/ref_error"import {schemaHasRulesButRef} from "../../compile/util"
export type DiscriminatorError = DiscrErrorObj<DiscrError.Tag> | DiscrErrorObj<DiscrError.Mapping>
const error: KeywordErrorDefinition = { message: ({params: {discrError, tagName}}) => discrError === DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`, params: ({params: {discrError, tag, tagName}}) => _`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`,}
const def: CodeKeywordDefinition = { keyword: "discriminator", type: "object", schemaType: "object", error, code(cxt: KeywordCxt) { const {gen, data, schema, parentSchema, it} = cxt const {oneOf} = parentSchema if (!it.opts.discriminator) { throw new Error("discriminator: requires discriminator option") } const tagName = schema.propertyName if (typeof tagName != "string") throw new Error("discriminator: requires propertyName") if (schema.mapping) throw new Error("discriminator: mapping is not supported") if (!oneOf) throw new Error("discriminator: requires oneOf keyword") const valid = gen.let("valid", false) const tag = gen.const("tag", _`${data}${getProperty(tagName)}`) gen.if( _`typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, {discrError: DiscrError.Tag, tag, tagName}) ) cxt.ok(valid)
function validateMapping(): void { const mapping = getMapping() gen.if(false) for (const tagValue in mapping) { gen.elseIf(_`${tag} === ${tagValue}`) gen.assign(valid, applyTagSchema(mapping[tagValue])) } gen.else() cxt.error(false, {discrError: DiscrError.Mapping, tag, tagName}) gen.endIf() }
function applyTagSchema(schemaProp?: number): Name { const _valid = gen.name("valid") const schCxt = cxt.subschema({keyword: "oneOf", schemaProp}, _valid) cxt.mergeEvaluated(schCxt, Name) return _valid }
function getMapping(): {[T in string]?: number} { const oneOfMapping: {[T in string]?: number} = {} const topRequired = hasRequired(parentSchema) let tagRequired = true for (let i = 0; i < oneOf.length; i++) { let sch = oneOf[i] if (sch?.$ref && !schemaHasRulesButRef(sch, it.self.RULES)) { const ref = sch.$ref sch = resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref) if (sch instanceof SchemaEnv) sch = sch.schema if (sch === undefined) throw new MissingRefError(it.opts.uriResolver, it.baseId, ref) } const propSch = sch?.properties?.[tagName] if (typeof propSch != "object") { throw new Error( `discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"` ) } tagRequired = tagRequired && (topRequired || hasRequired(sch)) addMappings(propSch, i) } if (!tagRequired) throw new Error(`discriminator: "${tagName}" must be required`) return oneOfMapping
function hasRequired({required}: AnySchemaObject): boolean { return Array.isArray(required) && required.includes(tagName) }
function addMappings(sch: AnySchemaObject, i: number): void { if (sch.const) { addMapping(sch.const, i) } else if (sch.enum) { for (const tagValue of sch.enum) { addMapping(tagValue, i) } } else { throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`) } }
function addMapping(tagValue: unknown, i: number): void { if (typeof tagValue != "string" || tagValue in oneOfMapping) { throw new Error(`discriminator: "${tagName}" values must be unique strings`) } oneOfMapping[tagValue] = i } } },}
export default def123123456789101112version https://git-lfs.github.com/spec/v1oid sha256:537bcd41ac270d1a43417d742a1f9f55b319e6f213323f6b00edfbe38e88e7dasize 251import type {ErrorObject} from "../../types"
export enum DiscrError { Tag = "tag", Mapping = "mapping",}
export type DiscrErrorObj<E extends DiscrError> = ErrorObject< "discriminator", {error: E; tag: string; tagValue: unknown}, string>1231234567891011121314151617181920212223version https://git-lfs.github.com/spec/v1oid sha256:840c49657713cbbd6467274f270c77bf16a7ed8b3aedbee6bb5c587550282aeasize 698import type {Vocabulary} from "../types"import coreVocabulary from "./core"import validationVocabulary from "./validation"import getApplicatorVocabulary from "./applicator"import dynamicVocabulary from "./dynamic"import nextVocabulary from "./next"import unevaluatedVocabulary from "./unevaluated"import formatVocabulary from "./format"import {metadataVocabulary, contentVocabulary} from "./metadata"
const draft2020Vocabularies: Vocabulary[] = [ dynamicVocabulary, coreVocabulary, validationVocabulary, getApplicatorVocabulary(true), formatVocabulary, metadataVocabulary, contentVocabulary, nextVocabulary, unevaluatedVocabulary,]
export default draft2020Vocabularies1231234567891011121314151617version https://git-lfs.github.com/spec/v1oid sha256:9f8fd4fa8b2084b4cae951badc68de3a361e01eea06a158d530c4d55e92b5fb4size 496import type {Vocabulary} from "../types"import coreVocabulary from "./core"import validationVocabulary from "./validation"import getApplicatorVocabulary from "./applicator"import formatVocabulary from "./format"import {metadataVocabulary, contentVocabulary} from "./metadata"
const draft7Vocabularies: Vocabulary[] = [ coreVocabulary, validationVocabulary, getApplicatorVocabulary(), formatVocabulary, metadataVocabulary, contentVocabulary,]
export default draft7Vocabularies12312345678910111213141516171819202122232425262728293031version https://git-lfs.github.com/spec/v1oid sha256:bc8bb7636e8fff1add5d8c36577978f357731c2877fd4d4c59b620d6a8af1d8fsize 1122import type {CodeKeywordDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, getProperty, Code} from "../../compile/codegen"import N from "../../compile/names"import {SchemaEnv, compileSchema} from "../../compile"import {getValidate} from "../core/ref"
const def: CodeKeywordDefinition = { keyword: "$dynamicAnchor", schemaType: "string", code: (cxt) => dynamicAnchor(cxt, cxt.schema),}
export function dynamicAnchor(cxt: KeywordCxt, anchor: string): void { const {gen, it} = cxt it.schemaEnv.root.dynamicAnchors[anchor] = true const v = _`${N.dynamicAnchors}${getProperty(anchor)}` const validate = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt) gen.if(_`!${v}`, () => gen.assign(v, validate))}
function _getValidate(cxt: KeywordCxt): Code { const {schemaEnv, schema, self} = cxt.it const {root, baseId, localRefs, meta} = schemaEnv.root const {schemaId} = self.opts const sch = new SchemaEnv({schema, schemaId, root, baseId, localRefs, meta}) compileSchema.call(self, sch) return getValidate(cxt, sch)}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051version https://git-lfs.github.com/spec/v1oid sha256:92884e9923f4053155e5c1f13d5e176c17b47f0db65616bf031a4bb93faf969dsize 1797import type {CodeKeywordDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, getProperty, Code, Name} from "../../compile/codegen"import N from "../../compile/names"import {callRef} from "../core/ref"
const def: CodeKeywordDefinition = { keyword: "$dynamicRef", schemaType: "string", code: (cxt) => dynamicRef(cxt, cxt.schema),}
export function dynamicRef(cxt: KeywordCxt, ref: string): void { const {gen, keyword, it} = cxt if (ref[0] !== "#") throw new Error(`"${keyword}" only supports hash fragment reference`) const anchor = ref.slice(1) if (it.allErrors) { _dynamicRef() } else { const valid = gen.let("valid", false) _dynamicRef(valid) cxt.ok(valid) }
function _dynamicRef(valid?: Name): void { // TODO the assumption here is that `recursiveRef: #` always points to the root // of the schema object, which is not correct, because there may be $id that // makes # point to it, and the target schema may not contain dynamic/recursiveAnchor. // Because of that 2 tests in recursiveRef.json fail. // This is a similar problem to #815 (`$id` doesn't alter resolution scope for `{ "$ref": "#" }`). // (This problem is not tested in JSON-Schema-Test-Suite) if (it.schemaEnv.root.dynamicAnchors[anchor]) { const v = gen.let("_v", _`${N.dynamicAnchors}${getProperty(anchor)}`) gen.if(v, _callRef(v, valid), _callRef(it.validateName, valid)) } else { _callRef(it.validateName, valid)() } }
function _callRef(validate: Code, valid?: Name): () => void { return valid ? () => gen.block(() => { callRef(cxt, validate) gen.let(valid, true) }) : () => callRef(cxt, validate) }}
export default def123123456789version https://git-lfs.github.com/spec/v1oid sha256:c5188cd455c45b486350ed74bb08b6fb47db13bea6f218cce9d2cbf88044352bsize 328import type {Vocabulary} from "../../types"import dynamicAnchor from "./dynamicAnchor"import dynamicRef from "./dynamicRef"import recursiveAnchor from "./recursiveAnchor"import recursiveRef from "./recursiveRef"
const dynamic: Vocabulary = [dynamicAnchor, dynamicRef, recursiveAnchor, recursiveRef]
export default dynamic1231234567891011121314version https://git-lfs.github.com/spec/v1oid sha256:7d9e31d581249212f5c831d30d5398c43b6d7ce4d3dcb735880524016b3e8d6asize 401import type {CodeKeywordDefinition} from "../../types"import {dynamicAnchor} from "./dynamicAnchor"import {checkStrictMode} from "../../compile/util"
const def: CodeKeywordDefinition = { keyword: "$recursiveAnchor", schemaType: "boolean", code(cxt) { if (cxt.schema) dynamicAnchor(cxt, "") else checkStrictMode(cxt.it, "$recursiveAnchor: false is ignored") },}
export default def12312345678910version https://git-lfs.github.com/spec/v1oid sha256:6202321b7ce13fb3aec6d0180c3e78b6f91d768be57afef6b1693bd143577ee3size 253import type {CodeKeywordDefinition} from "../../types"import {dynamicRef} from "./dynamicRef"
const def: CodeKeywordDefinition = { keyword: "$recursiveRef", schemaType: "string", code: (cxt) => dynamicRef(cxt, cxt.schema),}
export default def123123456789101112131415161718version https://git-lfs.github.com/spec/v1oid sha256:ccf58af574cd4a8475346998967fa6229b163b6b52af2e9b0b30fa37338b8e2bsize 731import type {TypeError} from "../compile/validate/dataType"import type {ApplicatorKeywordError} from "./applicator"import type {ValidationKeywordError} from "./validation"import type {FormatError} from "./format/format"import type {UnevaluatedPropertiesError} from "./unevaluated/unevaluatedProperties"import type {UnevaluatedItemsError} from "./unevaluated/unevaluatedItems"import type {DependentRequiredError} from "./validation/dependentRequired"import type {DiscriminatorError} from "./discriminator"
export type DefinedError = | TypeError | ApplicatorKeywordError | ValidationKeywordError | FormatError | UnevaluatedPropertiesError | UnevaluatedItemsError | DependentRequiredError | DiscriminatorError123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120version https://git-lfs.github.com/spec/v1oid sha256:5cd796fed502ebe7f2c650b47daae97c28967dd17fa020df56ec861986d30148size 3987import type { AddedFormat, FormatValidator, AsyncFormatValidator, CodeKeywordDefinition, KeywordErrorDefinition, ErrorObject,} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, str, nil, or, Code, getProperty, regexpCode} from "../../compile/codegen"
type FormatValidate = | FormatValidator<string> | FormatValidator<number> | AsyncFormatValidator<string> | AsyncFormatValidator<number> | RegExp | string | true
export type FormatError = ErrorObject<"format", {format: string}, string | {$data: string}>
const error: KeywordErrorDefinition = { message: ({schemaCode}) => str`must match format "${schemaCode}"`, params: ({schemaCode}) => _`{format: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: "format", type: ["number", "string"], schemaType: "string", $data: true, error, code(cxt: KeywordCxt, ruleType?: string) { const {gen, data, $data, schema, schemaCode, it} = cxt const {opts, errSchemaPath, schemaEnv, self} = it if (!opts.validateFormats) return
if ($data) validate$DataFormat() else validateFormat()
function validate$DataFormat(): void { const fmts = gen.scopeValue("formats", { ref: self.formats, code: opts.code.formats, }) const fDef = gen.const("fDef", _`${fmts}[${schemaCode}]`) const fType = gen.let("fType") const format = gen.let("format") // TODO simplify gen.if( _`typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, _`${fDef}.type || "string"`).assign(format, _`${fDef}.validate`), () => gen.assign(fType, _`"string"`).assign(format, fDef) ) cxt.fail$data(or(unknownFmt(), invalidFmt()))
function unknownFmt(): Code { if (opts.strictSchema === false) return nil return _`${schemaCode} && !${format}` }
function invalidFmt(): Code { const callFormat = schemaEnv.$async ? _`(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))` : _`${format}(${data})` const validData = _`(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))` return _`${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}` } }
function validateFormat(): void { const formatDef: AddedFormat | undefined = self.formats[schema] if (!formatDef) { unknownFormat() return } if (formatDef === true) return const [fmtType, format, fmtRef] = getFormat(formatDef) if (fmtType === ruleType) cxt.pass(validCondition())
function unknownFormat(): void { if (opts.strictSchema === false) { self.logger.warn(unknownMsg()) return } throw new Error(unknownMsg())
function unknownMsg(): string { return `unknown format "${schema as string}" ignored in schema at path "${errSchemaPath}"` } }
function getFormat(fmtDef: AddedFormat): [string, FormatValidate, Code] { const code = fmtDef instanceof RegExp ? regexpCode(fmtDef) : opts.code.formats ? _`${opts.code.formats}${getProperty(schema)}` : undefined const fmt = gen.scopeValue("formats", {key: schema, ref: fmtDef, code}) if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) { return [fmtDef.type || "string", fmtDef.validate, _`${fmt}.validate`] }
return ["string", fmtDef, fmt] }
function validCondition(): Code { if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) { if (!schemaEnv.$async) throw new Error("async format in sync schema") return _`await ${fmtRef}(${data})` } return typeof format == "function" ? _`${fmtRef}(${data})` : _`${fmtRef}.test(${data})` } } },}
export default def123123456version https://git-lfs.github.com/spec/v1oid sha256:804a833df34f93e7cd1a1809782f65c1ac89610ac736045308d27b659264a40asize 148import type {Vocabulary} from "../../types"import formatKeyword from "./format"
const format: Vocabulary = [formatKeyword]
export default format1231234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889version https://git-lfs.github.com/spec/v1oid sha256:9dd6dd40e98239c10d6771c0a0d107e238c12af4b3c5932fe623de649588de1dsize 2656import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, not, getProperty, Name} from "../../compile/codegen"import {checkMetadata} from "./metadata"import {checkNullableObject} from "./nullable"import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error"import {DiscrError, DiscrErrorObj} from "../discriminator/types"
export type JTDDiscriminatorError = | _JTDTypeError<"discriminator", "object", string> | DiscrErrorObj<DiscrError.Tag> | DiscrErrorObj<DiscrError.Mapping>
const error: KeywordErrorDefinition = { message: (cxt) => { const {schema, params} = cxt return params.discrError ? params.discrError === DiscrError.Tag ? `tag "${schema}" must be string` : `value of tag "${schema}" must be in mapping` : typeErrorMessage(cxt, "object") }, params: (cxt) => { const {schema, params} = cxt return params.discrError ? _`{error: ${params.discrError}, tag: ${schema}, tagValue: ${params.tag}}` : typeErrorParams(cxt, "object") },}
const def: CodeKeywordDefinition = { keyword: "discriminator", schemaType: "string", implements: ["mapping"], error, code(cxt: KeywordCxt) { checkMetadata(cxt) const {gen, data, schema, parentSchema} = cxt const [valid, cond] = checkNullableObject(cxt, data)
gen.if(cond) validateDiscriminator() gen.elseIf(not(valid)) cxt.error() gen.endIf() cxt.ok(valid)
function validateDiscriminator(): void { const tag = gen.const("tag", _`${data}${getProperty(schema)}`) gen.if(_`${tag} === undefined`) cxt.error(false, {discrError: DiscrError.Tag, tag}) gen.elseIf(_`typeof ${tag} == "string"`) validateMapping(tag) gen.else() cxt.error(false, {discrError: DiscrError.Tag, tag}, {instancePath: schema}) gen.endIf() }
function validateMapping(tag: Name): void { gen.if(false) for (const tagValue in parentSchema.mapping) { gen.elseIf(_`${tag} === ${tagValue}`) gen.assign(valid, applyTagSchema(tagValue)) } gen.else() cxt.error( false, {discrError: DiscrError.Mapping, tag}, {instancePath: schema, schemaPath: "mapping", parentSchema: true} ) gen.endIf() }
function applyTagSchema(schemaProp: string): Name { const _valid = gen.name("valid") cxt.subschema( { keyword: "mapping", schemaProp, jtdDiscriminator: schema, }, _valid ) return _valid } },}
export default def1231234567891011121314151617181920212223242526272829303132version https://git-lfs.github.com/spec/v1oid sha256:54c00bc71c6bc0f5055c49fa0b6803db07832e5f77aadb1e55e5e045b3a4ad33size 976import type {CodeKeywordDefinition, SchemaObject} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {alwaysValidSchema} from "../../compile/util"import {validateArray} from "../code"import {_, not} from "../../compile/codegen"import {checkMetadata} from "./metadata"import {checkNullable} from "./nullable"import {typeError, _JTDTypeError} from "./error"
export type JTDElementsError = _JTDTypeError<"elements", "array", SchemaObject>
const def: CodeKeywordDefinition = { keyword: "elements", schemaType: "object", error: typeError("array"), code(cxt: KeywordCxt) { checkMetadata(cxt) const {gen, data, schema, it} = cxt if (alwaysValidSchema(it, schema)) return const [valid] = checkNullable(cxt) gen.if(not(valid), () => gen.if( _`Array.isArray(${data})`, () => gen.assign(valid, validateArray(cxt)), () => cxt.error() ) ) cxt.ok(valid) },}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142434445version https://git-lfs.github.com/spec/v1oid sha256:a55ae1c6b7d9ac0e9053e71da407efe41b3156cc0db7091bcd20a9d8897844ddsize 1627import type {CodeKeywordDefinition, KeywordErrorDefinition, ErrorObject} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, or, and, Code} from "../../compile/codegen"import {checkMetadata} from "./metadata"import {checkNullable} from "./nullable"
export type JTDEnumError = ErrorObject<"enum", {allowedValues: string[]}, string[]>
const error: KeywordErrorDefinition = { message: "must be equal to one of the allowed values", params: ({schemaCode}) => _`{allowedValues: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: "enum", schemaType: "array", error, code(cxt: KeywordCxt) { checkMetadata(cxt) const {gen, data, schema, schemaValue, parentSchema, it} = cxt if (schema.length === 0) throw new Error("enum must have non-empty array") if (schema.length !== new Set(schema).size) throw new Error("enum items must be unique") let valid: Code const isString = _`typeof ${data} == "string"` if (schema.length >= it.opts.loopEnum) { let cond: Code ;[valid, cond] = checkNullable(cxt, isString) gen.if(cond, loopEnum) } else { /* istanbul ignore if */ if (!Array.isArray(schema)) throw new Error("ajv implementation error") valid = and(isString, or(...schema.map((value: string) => _`${data} === ${value}`))) if (parentSchema.nullable) valid = or(_`${data} === null`, valid) } cxt.pass(valid)
function loopEnum(): void { gen.forOf("v", schemaValue as Code, (v) => gen.if(_`${valid} = ${data} === ${v}`, () => gen.break()) ) } },}
export default def1231234567891011121314151617181920212223version https://git-lfs.github.com/spec/v1oid sha256:e1bdb9dfada76ee42308e134f2e74027ea8398997961a3bae08cd10c792272c5size 746import type {KeywordErrorDefinition, KeywordErrorCxt, ErrorObject} from "../../types"import {_, Code} from "../../compile/codegen"
export type _JTDTypeError<K extends string, T extends string, S> = ErrorObject< K, {type: T; nullable: boolean}, S>
export function typeError(t: string): KeywordErrorDefinition { return { message: (cxt) => typeErrorMessage(cxt, t), params: (cxt) => typeErrorParams(cxt, t), }}
export function typeErrorMessage({parentSchema}: KeywordErrorCxt, t: string): string { return parentSchema?.nullable ? `must be ${t} or null` : `must be ${t}`}
export function typeErrorParams({parentSchema}: KeywordErrorCxt, t: string): Code { return _`{type: ${t}, nullable: ${!!parentSchema?.nullable}}`}12312345678910111213141516171819202122232425262728293031323334353637version https://git-lfs.github.com/spec/v1oid sha256:4ca3295374abddb3c03ada3fdc52b9b7cb175046769a3eef60605bef8a6ef85asize 1007import type {Vocabulary} from "../../types"import refKeyword from "./ref"import typeKeyword, {JTDTypeError} from "./type"import enumKeyword, {JTDEnumError} from "./enum"import elements, {JTDElementsError} from "./elements"import properties, {JTDPropertiesError} from "./properties"import optionalProperties from "./optionalProperties"import discriminator, {JTDDiscriminatorError} from "./discriminator"import values, {JTDValuesError} from "./values"import union from "./union"import metadata from "./metadata"
const jtdVocabulary: Vocabulary = [ "definitions", refKeyword, typeKeyword, enumKeyword, elements, properties, optionalProperties, discriminator, values, union, metadata, {keyword: "additionalProperties", schemaType: "boolean"}, {keyword: "nullable", schemaType: "boolean"},]
export default jtdVocabulary
export type JTDErrorObject = | JTDTypeError | JTDEnumError | JTDElementsError | JTDPropertiesError | JTDDiscriminatorError | JTDValuesError123123456789101112131415161718192021222324version https://git-lfs.github.com/spec/v1oid sha256:558fcb3d3b5e39a9a967326ea6a35160bd485755d587c5faafb644e25d0c0f01size 716import {KeywordCxt} from "../../ajv"import type {CodeKeywordDefinition} from "../../types"import {alwaysValidSchema} from "../../compile/util"
const def: CodeKeywordDefinition = { keyword: "metadata", schemaType: "object", code(cxt: KeywordCxt) { checkMetadata(cxt) const {gen, schema, it} = cxt if (alwaysValidSchema(it, schema)) return const valid = gen.name("valid") cxt.subschema({keyword: "metadata", jtdMetadata: true}, valid) cxt.ok(valid) },}
export function checkMetadata({it, keyword}: KeywordCxt, metadata?: boolean): void { if (it.jtdMetadata !== metadata) { throw new Error(`JTD: "${keyword}" cannot be used in this schema location`) }}
export default def123123456789101112131415161718192021version https://git-lfs.github.com/spec/v1oid sha256:75b370cb5ad4c36ff85a57fb9305a8018b5363666f0a5ac21c8de99d984b6bb8size 649import type {KeywordCxt} from "../../compile/validate"import {_, not, nil, Code, Name} from "../../compile/codegen"
export function checkNullable( {gen, data, parentSchema}: KeywordCxt, cond: Code = nil): [Name, Code] { const valid = gen.name("valid") if (parentSchema.nullable) { gen.let(valid, _`${data} === null`) cond = not(valid) } else { gen.let(valid, false) } return [valid, cond]}
export function checkNullableObject(cxt: KeywordCxt, cond: Code): [Name, Code] { const [valid, cond_] = checkNullable(cxt, cond) return [valid, _`${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`]}123123456789101112131415version https://git-lfs.github.com/spec/v1oid sha256:03fdaf041fd433857e78c3b867ad1e6c1f0a964c0292498981e238b40a2a4e77size 394import type {CodeKeywordDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {validateProperties, error} from "./properties"
const def: CodeKeywordDefinition = { keyword: "optionalProperties", schemaType: "object", error, code(cxt: KeywordCxt) { if (cxt.parentSchema.properties) return validateProperties(cxt) },}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184version https://git-lfs.github.com/spec/v1oid sha256:930071681288045214e10af6065f5d6c7f6ea599d07c607f345b609bac4bf8e5size 6244import type { CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition, SchemaObject,} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {propertyInData, allSchemaProperties, isOwnProperty} from "../code"import {alwaysValidSchema, schemaRefOrVal} from "../../compile/util"import {_, and, not, Code, Name} from "../../compile/codegen"import {checkMetadata} from "./metadata"import {checkNullableObject} from "./nullable"import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error"
enum PropError { Additional = "additional", Missing = "missing",}
type PropKeyword = "properties" | "optionalProperties"
type PropSchema = {[P in string]?: SchemaObject}
export type JTDPropertiesError = | _JTDTypeError<PropKeyword, "object", PropSchema> | ErrorObject<PropKeyword, {error: PropError.Additional; additionalProperty: string}, PropSchema> | ErrorObject<PropKeyword, {error: PropError.Missing; missingProperty: string}, PropSchema>
export const error: KeywordErrorDefinition = { message: (cxt) => { const {params} = cxt return params.propError ? params.propError === PropError.Additional ? "must NOT have additional properties" : `must have property '${params.missingProperty}'` : typeErrorMessage(cxt, "object") }, params: (cxt) => { const {params} = cxt return params.propError ? params.propError === PropError.Additional ? _`{error: ${params.propError}, additionalProperty: ${params.additionalProperty}}` : _`{error: ${params.propError}, missingProperty: ${params.missingProperty}}` : typeErrorParams(cxt, "object") },}
const def: CodeKeywordDefinition = { keyword: "properties", schemaType: "object", error, code: validateProperties,}
// const error: KeywordErrorDefinition = {// message: "should NOT have additional properties",// params: ({params}) => _`{additionalProperty: ${params.additionalProperty}}`,// }
export function validateProperties(cxt: KeywordCxt): void { checkMetadata(cxt) const {gen, data, parentSchema, it} = cxt const {additionalProperties, nullable} = parentSchema if (it.jtdDiscriminator && nullable) throw new Error("JTD: nullable inside discriminator mapping") if (commonProperties()) { throw new Error("JTD: properties and optionalProperties have common members") } const [allProps, properties] = schemaProperties("properties") const [allOptProps, optProperties] = schemaProperties("optionalProperties") if (properties.length === 0 && optProperties.length === 0 && additionalProperties) { return }
const [valid, cond] = it.jtdDiscriminator === undefined ? checkNullableObject(cxt, data) : [gen.let("valid", false), true] gen.if(cond, () => gen.assign(valid, true).block(() => { validateProps(properties, "properties", true) validateProps(optProperties, "optionalProperties") if (!additionalProperties) validateAdditional() }) ) cxt.pass(valid)
function commonProperties(): boolean { const props = parentSchema.properties as Record<string, any> | undefined const optProps = parentSchema.optionalProperties as Record<string, any> | undefined if (!(props && optProps)) return false for (const p in props) { if (Object.prototype.hasOwnProperty.call(optProps, p)) return true } return false }
function schemaProperties(keyword: string): [string[], string[]] { const schema = parentSchema[keyword] const allPs = schema ? allSchemaProperties(schema) : [] if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) { throw new Error(`JTD: discriminator tag used in ${keyword}`) } const ps = allPs.filter((p) => !alwaysValidSchema(it, schema[p])) return [allPs, ps] }
function validateProps(props: string[], keyword: string, required?: boolean): void { const _valid = gen.var("valid") for (const prop of props) { gen.if( propertyInData(gen, data, prop, it.opts.ownProperties), () => applyPropertySchema(prop, keyword, _valid), () => missingProperty(prop) ) cxt.ok(_valid) }
function missingProperty(prop: string): void { if (required) { gen.assign(_valid, false) cxt.error(false, {propError: PropError.Missing, missingProperty: prop}, {schemaPath: prop}) } else { gen.assign(_valid, true) } } }
function applyPropertySchema(prop: string, keyword: string, _valid: Name): void { cxt.subschema( { keyword, schemaProp: prop, dataProp: prop, }, _valid ) }
function validateAdditional(): void { gen.forIn("key", data, (key: Name) => { const addProp = isAdditional(key, allProps, "properties", it.jtdDiscriminator) const addOptProp = isAdditional(key, allOptProps, "optionalProperties") const extra = addProp === true ? addOptProp : addOptProp === true ? addProp : and(addProp, addOptProp) gen.if(extra, () => { if (it.opts.removeAdditional) { gen.code(_`delete ${data}[${key}]`) } else { cxt.error( false, {propError: PropError.Additional, additionalProperty: key}, {instancePath: key, parentSchema: true} ) if (!it.opts.allErrors) gen.break() } }) }) }
function isAdditional( key: Name, props: string[], keyword: string, jtdDiscriminator?: string ): Code | true { let additional: Code | boolean if (props.length > 8) { // TODO maybe an option instead of hard-coded 8? const propsSchema = schemaRefOrVal(it, parentSchema[keyword], keyword) additional = not(isOwnProperty(gen, propsSchema as Code, key)) if (jtdDiscriminator !== undefined) { additional = and(additional, _`${key} !== ${jtdDiscriminator}`) } } else if (props.length || jtdDiscriminator !== undefined) { const ps = jtdDiscriminator === undefined ? props : [jtdDiscriminator].concat(props) additional = and(...ps.map((p) => _`${key} !== ${p}`)) } else { additional = true } return additional }}
export default def12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576version https://git-lfs.github.com/spec/v1oid sha256:f7dc8a31ad5764cc0c44725713130d5b656ead77483429226507da4dfd24ad2dsize 2346import type {CodeKeywordDefinition, AnySchemaObject} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {compileSchema, SchemaEnv} from "../../compile"import {_, not, nil, stringify} from "../../compile/codegen"import MissingRefError from "../../compile/ref_error"import N from "../../compile/names"import {getValidate, callRef} from "../core/ref"import {checkMetadata} from "./metadata"
const def: CodeKeywordDefinition = { keyword: "ref", schemaType: "string", code(cxt: KeywordCxt) { checkMetadata(cxt) const {gen, data, schema: ref, parentSchema, it} = cxt const { schemaEnv: {root}, } = it const valid = gen.name("valid") if (parentSchema.nullable) { gen.var(valid, _`${data} === null`) gen.if(not(valid), validateJtdRef) } else { gen.var(valid, false) validateJtdRef() } cxt.ok(valid)
function validateJtdRef(): void { const refSchema = (root.schema as AnySchemaObject).definitions?.[ref] if (!refSchema) { throw new MissingRefError(it.opts.uriResolver, "", ref, `No definition ${ref}`) } if (hasRef(refSchema) || !it.opts.inlineRefs) callValidate(refSchema) else inlineRefSchema(refSchema) }
function callValidate(schema: AnySchemaObject): void { const sch = compileSchema.call( it.self, new SchemaEnv({schema, root, schemaPath: `/definitions/${ref}`}) ) const v = getValidate(cxt, sch) const errsCount = gen.const("_errs", N.errors) callRef(cxt, v, sch, sch.$async) gen.assign(valid, _`${errsCount} === ${N.errors}`) }
function inlineRefSchema(schema: AnySchemaObject): void { const schName = gen.scopeValue( "schema", it.opts.code.source === true ? {ref: schema, code: stringify(schema)} : {ref: schema} ) cxt.subschema( { schema, dataTypes: [], schemaPath: nil, topSchemaRef: schName, errSchemaPath: `/definitions/${ref}`, }, valid ) } },}
export function hasRef(schema: AnySchemaObject): boolean { for (const key in schema) { let sch: AnySchemaObject if (key === "ref" || (typeof (sch = schema[key]) == "object" && hasRef(sch))) return true } return false}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475version https://git-lfs.github.com/spec/v1oid sha256:0e6c6bb43fa81bff1cb4ba3f4d6d73379f3e013efaa01b790768fa0a5095cd45size 2547import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, nil, or, Code} from "../../compile/codegen"import validTimestamp from "../../runtime/timestamp"import {useFunc} from "../../compile/util"import {checkMetadata} from "./metadata"import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error"
export type JTDTypeError = _JTDTypeError<"type", JTDType, JTDType>
export type IntType = "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32"
export const intRange: {[T in IntType]: [number, number, number]} = { int8: [-128, 127, 3], uint8: [0, 255, 3], int16: [-32768, 32767, 5], uint16: [0, 65535, 5], int32: [-2147483648, 2147483647, 10], uint32: [0, 4294967295, 10],}
export type JTDType = "boolean" | "string" | "timestamp" | "float32" | "float64" | IntType
const error: KeywordErrorDefinition = { message: (cxt) => typeErrorMessage(cxt, cxt.schema), params: (cxt) => typeErrorParams(cxt, cxt.schema),}
function timestampCode(cxt: KeywordCxt): Code { const {gen, data, it} = cxt const {timestamp, allowDate} = it.opts if (timestamp === "date") return _`${data} instanceof Date ` const vts = useFunc(gen, validTimestamp) const allowDateArg = allowDate ? _`, true` : nil const validString = _`typeof ${data} == "string" && ${vts}(${data}${allowDateArg})` return timestamp === "string" ? validString : or(_`${data} instanceof Date`, validString)}
const def: CodeKeywordDefinition = { keyword: "type", schemaType: "string", error, code(cxt: KeywordCxt) { checkMetadata(cxt) const {data, schema, parentSchema, it} = cxt let cond: Code switch (schema) { case "boolean": case "string": cond = _`typeof ${data} == ${schema}` break case "timestamp": { cond = timestampCode(cxt) break } case "float32": case "float64": cond = _`typeof ${data} == "number"` break default: { const sch = schema as IntType cond = _`typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)` if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) { if (sch === "uint32") cond = _`${cond} && ${data} >= 0` } else { const [min, max] = intRange[sch] cond = _`${cond} && ${data} >= ${min} && ${data} <= ${max}` } } } cxt.pass(parentSchema.nullable ? or(_`${data} === null`, cond) : cond) },}
export default def123123456789101112version https://git-lfs.github.com/spec/v1oid sha256:1dd265ce69eebbd46cd395b0b9d98ca22d8e681d0ab787e6409cb126450c9536size 292import type {CodeKeywordDefinition} from "../../types"import {validateUnion} from "../code"
const def: CodeKeywordDefinition = { keyword: "union", schemaType: "array", trackErrors: true, code: validateUnion, error: {message: "must match a schema in union"},}
export default def12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758version https://git-lfs.github.com/spec/v1oid sha256:86236891ca9a9f77f7df5d399be026406d0f375c0a5d8f6d0749859dea245cddsize 1681import type {CodeKeywordDefinition, SchemaObject} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {alwaysValidSchema, Type} from "../../compile/util"import {not, or, Name} from "../../compile/codegen"import {checkMetadata} from "./metadata"import {checkNullableObject} from "./nullable"import {typeError, _JTDTypeError} from "./error"
export type JTDValuesError = _JTDTypeError<"values", "object", SchemaObject>
const def: CodeKeywordDefinition = { keyword: "values", schemaType: "object", error: typeError("object"), code(cxt: KeywordCxt) { checkMetadata(cxt) const {gen, data, schema, it} = cxt const [valid, cond] = checkNullableObject(cxt, data) if (alwaysValidSchema(it, schema)) { gen.if(not(or(cond, valid)), () => cxt.error()) } else { gen.if(cond) gen.assign(valid, validateMap()) gen.elseIf(not(valid)) cxt.error() gen.endIf() } cxt.ok(valid)
function validateMap(): Name | boolean { const _valid = gen.name("valid") if (it.allErrors) { const validMap = gen.let("valid", true) validateValues(() => gen.assign(validMap, false)) return validMap } gen.var(_valid, true) validateValues(() => gen.break()) return _valid
function validateValues(notValid: () => void): void { gen.forIn("key", data, (key) => { cxt.subschema( { keyword: "values", dataProp: key, dataPropType: Type.Str, }, _valid ) gen.if(not(_valid), notValid) }) } } },}
export default def1231234567891011121314151617version https://git-lfs.github.com/spec/v1oid sha256:a0b32538e6d2c93c7fd10aef9963d990d24d9579d2494350a23f3501300817d1size 304import type {Vocabulary} from "../types"
export const metadataVocabulary: Vocabulary = [ "title", "description", "default", "deprecated", "readOnly", "writeOnly", "examples",]
export const contentVocabulary: Vocabulary = [ "contentMediaType", "contentEncoding", "contentSchema",]12312345678version https://git-lfs.github.com/spec/v1oid sha256:b953c63e395e4e0c95e048ae8778473a744e1d7a7b5fa8c57733c1bfbf7ce443size 320import type {Vocabulary} from "../types"import dependentRequired from "./validation/dependentRequired"import dependentSchemas from "./applicator/dependentSchemas"import limitContains from "./validation/limitContains"
const next: Vocabulary = [dependentRequired, dependentSchemas, limitContains]
export default next1231234567version https://git-lfs.github.com/spec/v1oid sha256:0d44afd298469f01304d72a5cf7da11303367fa506200c46785cee4bd3350f40size 257import type {Vocabulary} from "../../types"import unevaluatedProperties from "./unevaluatedProperties"import unevaluatedItems from "./unevaluatedItems"
const unevaluated: Vocabulary = [unevaluatedProperties, unevaluatedItems]
export default unevaluated1231234567891011121314151617181920212223242526272829303132333435363738394041424344454647version https://git-lfs.github.com/spec/v1oid sha256:c19c3d3e0b290171f674d3dbacc52d946f9e4325f2223355a055e741c5dbbbb2size 1524import type { CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition, AnySchema,} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, str, not, Name} from "../../compile/codegen"import {alwaysValidSchema, Type} from "../../compile/util"
export type UnevaluatedItemsError = ErrorObject<"unevaluatedItems", {limit: number}, AnySchema>
const error: KeywordErrorDefinition = { message: ({params: {len}}) => str`must NOT have more than ${len} items`, params: ({params: {len}}) => _`{limit: ${len}}`,}
const def: CodeKeywordDefinition = { keyword: "unevaluatedItems", type: "array", schemaType: ["boolean", "object"], error, code(cxt: KeywordCxt) { const {gen, schema, data, it} = cxt const items = it.items || 0 if (items === true) return const len = gen.const("len", _`${data}.length`) if (schema === false) { cxt.setParams({len: items}) cxt.fail(_`${len} > ${items}`) } else if (typeof schema == "object" && !alwaysValidSchema(it, schema)) { const valid = gen.var("valid", _`${len} <= ${items}`) gen.if(not(valid), () => validateItems(valid, items)) cxt.ok(valid) } it.items = true
function validateItems(valid: Name, from: Name | number): void { gen.forRange("i", from, len, (i) => { cxt.subschema({keyword: "unevaluatedItems", dataProp: i, dataPropType: Type.Num}, valid) if (!it.allErrors) gen.if(not(valid), () => gen.break()) }) } },}
export default def12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485version https://git-lfs.github.com/spec/v1oid sha256:7d725ffb348774d31cc697cc6b632a43431b3d2d92edb819fd7341902340c6desize 2440import type { CodeKeywordDefinition, KeywordErrorDefinition, ErrorObject, AnySchema,} from "../../types"import {_, not, and, Name, Code} from "../../compile/codegen"import {alwaysValidSchema, Type} from "../../compile/util"import N from "../../compile/names"
export type UnevaluatedPropertiesError = ErrorObject< "unevaluatedProperties", {unevaluatedProperty: string}, AnySchema>
const error: KeywordErrorDefinition = { message: "must NOT have unevaluated properties", params: ({params}) => _`{unevaluatedProperty: ${params.unevaluatedProperty}}`,}
const def: CodeKeywordDefinition = { keyword: "unevaluatedProperties", type: "object", schemaType: ["boolean", "object"], trackErrors: true, error, code(cxt) { const {gen, schema, data, errsCount, it} = cxt /* istanbul ignore if */ if (!errsCount) throw new Error("ajv implementation error") const {allErrors, props} = it if (props instanceof Name) { gen.if(_`${props} !== true`, () => gen.forIn("key", data, (key: Name) => gen.if(unevaluatedDynamic(props, key), () => unevaluatedPropCode(key)) ) ) } else if (props !== true) { gen.forIn("key", data, (key: Name) => props === undefined ? unevaluatedPropCode(key) : gen.if(unevaluatedStatic(props, key), () => unevaluatedPropCode(key)) ) } it.props = true cxt.ok(_`${errsCount} === ${N.errors}`)
function unevaluatedPropCode(key: Name): void { if (schema === false) { cxt.setParams({unevaluatedProperty: key}) cxt.error() if (!allErrors) gen.break() return }
if (!alwaysValidSchema(it, schema)) { const valid = gen.name("valid") cxt.subschema( { keyword: "unevaluatedProperties", dataProp: key, dataPropType: Type.Str, }, valid ) if (!allErrors) gen.if(not(valid), () => gen.break()) } }
function unevaluatedDynamic(evaluatedProps: Name, key: Name): Code { return _`!${evaluatedProps} || !${evaluatedProps}[${key}]` }
function unevaluatedStatic(evaluatedProps: {[K in string]?: true}, key: Name): Code { const ps: Code[] = [] for (const p in evaluatedProps) { if (evaluatedProps[p] === true) ps.push(_`${key} !== ${p}`) } return and(...ps) } },}
export default def12312345678910111213141516171819202122232425262728version https://git-lfs.github.com/spec/v1oid sha256:9dc3c40d6260158b2ee34dadadbc0e738cad939fc725cc1d2f5120bd43768ed5size 863import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_} from "../../compile/codegen"import {useFunc} from "../../compile/util"import equal from "../../runtime/equal"
export type ConstError = ErrorObject<"const", {allowedValue: any}>
const error: KeywordErrorDefinition = { message: "must be equal to constant", params: ({schemaCode}) => _`{allowedValue: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: "const", $data: true, error, code(cxt: KeywordCxt) { const {gen, data, $data, schemaCode, schema} = cxt if ($data || (schema && typeof schema == "object")) { cxt.fail$data(_`!${useFunc(gen, equal)}(${data}, ${schemaCode})`) } else { cxt.fail(_`${schema} !== ${data}`) } },}
export default def1231234567891011121314151617181920212223version https://git-lfs.github.com/spec/v1oid sha256:082d569e899aca88dbe28bdf6a0c6c2efa120e107fe4d1244ecf3a0b17fef45bsize 510import type {CodeKeywordDefinition, ErrorObject} from "../../types"import { validatePropertyDeps, error, DependenciesErrorParams, PropertyDependencies,} from "../applicator/dependencies"
export type DependentRequiredError = ErrorObject< "dependentRequired", DependenciesErrorParams, PropertyDependencies>
const def: CodeKeywordDefinition = { keyword: "dependentRequired", type: "object", schemaType: "object", error, code: (cxt) => validatePropertyDeps(cxt),}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354version https://git-lfs.github.com/spec/v1oid sha256:f62f760dda52c2dbc053ef7b7012aa9db10d3af65e8b1dc5defcaf2ba9c25911size 1837import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, or, Name, Code} from "../../compile/codegen"import {useFunc} from "../../compile/util"import equal from "../../runtime/equal"
export type EnumError = ErrorObject<"enum", {allowedValues: any[]}, any[] | {$data: string}>
const error: KeywordErrorDefinition = { message: "must be equal to one of the allowed values", params: ({schemaCode}) => _`{allowedValues: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: "enum", schemaType: "array", $data: true, error, code(cxt: KeywordCxt) { const {gen, data, $data, schema, schemaCode, it} = cxt if (!$data && schema.length === 0) throw new Error("enum must have non-empty array") const useLoop = schema.length >= it.opts.loopEnum let eql: Name | undefined const getEql = (): Name => (eql ??= useFunc(gen, equal))
let valid: Code if (useLoop || $data) { valid = gen.let("valid") cxt.block$data(valid, loopEnum) } else { /* istanbul ignore if */ if (!Array.isArray(schema)) throw new Error("ajv implementation error") const vSchema = gen.const("vSchema", schemaCode) valid = or(...schema.map((_x: unknown, i: number) => equalCode(vSchema, i))) } cxt.pass(valid)
function loopEnum(): void { gen.assign(valid, false) gen.forOf("v", schemaCode as Code, (v) => gen.if(_`${getEql()}(${data}, ${v})`, () => gen.assign(valid, true).break()) ) }
function equalCode(vSchema: Name, i: number): Code { const sch = schema[i] return typeof sch === "object" && sch !== null ? _`${getEql()}(${data}, ${vSchema}[${i}])` : _`${data} === ${sch}` } },}
export default def12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849version https://git-lfs.github.com/spec/v1oid sha256:72a7be83642b3da6317dc9661bfbc8a8f521773812ac6e5c58ddee1c4386a86csize 1271import type {ErrorObject, Vocabulary} from "../../types"import limitNumber, {LimitNumberError} from "./limitNumber"import multipleOf, {MultipleOfError} from "./multipleOf"import limitLength from "./limitLength"import pattern, {PatternError} from "./pattern"import limitProperties from "./limitProperties"import required, {RequiredError} from "./required"import limitItems from "./limitItems"import uniqueItems, {UniqueItemsError} from "./uniqueItems"import constKeyword, {ConstError} from "./const"import enumKeyword, {EnumError} from "./enum"
const validation: Vocabulary = [ // number limitNumber, multipleOf, // string limitLength, pattern, // object limitProperties, required, // array limitItems, uniqueItems, // any {keyword: "type", schemaType: ["string", "array"]}, {keyword: "nullable", schemaType: "boolean"}, constKeyword, enumKeyword,]
export default validation
type LimitError = ErrorObject< "maxItems" | "minItems" | "minProperties" | "maxProperties" | "minLength" | "maxLength", {limit: number}, number | {$data: string}>
export type ValidationKeywordError = | LimitError | LimitNumberError | MultipleOfError | PatternError | RequiredError | UniqueItemsError | ConstError | EnumError12312345678910111213141516version https://git-lfs.github.com/spec/v1oid sha256:3097c6f451ff7a527cbce136a08817114ee615f1b29221195cee45dfc89675e5size 485import type {CodeKeywordDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {checkStrictMode} from "../../compile/util"
const def: CodeKeywordDefinition = { keyword: ["maxContains", "minContains"], type: "array", schemaType: "number", code({keyword, parentSchema, it}: KeywordCxt) { if (parentSchema.contains === undefined) { checkStrictMode(it, `"${keyword}" without "contains" is ignored`) } },}
export default def1231234567891011121314151617181920212223242526version https://git-lfs.github.com/spec/v1oid sha256:32098cc56bcd9ff44bfa83b1015a3bc2bb7d2f8f7eecb3113929df732faa8176size 812import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, str, operators} from "../../compile/codegen"
const error: KeywordErrorDefinition = { message({keyword, schemaCode}) { const comp = keyword === "maxItems" ? "more" : "fewer" return str`must NOT have ${comp} than ${schemaCode} items` }, params: ({schemaCode}) => _`{limit: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: ["maxItems", "minItems"], type: "array", schemaType: "number", $data: true, error, code(cxt: KeywordCxt) { const {keyword, data, schemaCode} = cxt const op = keyword === "maxItems" ? operators.GT : operators.LT cxt.fail$data(_`${data}.length ${op} ${schemaCode}`) },}
export default def123123456789101112131415161718192021222324252627282930version https://git-lfs.github.com/spec/v1oid sha256:72afbaaa2718abe23156d8bb4af09fdc98a12054fe3c559b82e22718dbedb7desize 1025import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, str, operators} from "../../compile/codegen"import {useFunc} from "../../compile/util"import ucs2length from "../../runtime/ucs2length"
const error: KeywordErrorDefinition = { message({keyword, schemaCode}) { const comp = keyword === "maxLength" ? "more" : "fewer" return str`must NOT have ${comp} than ${schemaCode} characters` }, params: ({schemaCode}) => _`{limit: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: ["maxLength", "minLength"], type: "string", schemaType: "number", $data: true, error, code(cxt: KeywordCxt) { const {keyword, data, schemaCode, it} = cxt const op = keyword === "maxLength" ? operators.GT : operators.LT const len = it.opts.unicode === false ? _`${data}.length` : _`${useFunc(cxt.gen, ucs2length)}(${data})` cxt.fail$data(_`${len} ${op} ${schemaCode}`) },}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142version https://git-lfs.github.com/spec/v1oid sha256:61bedba4a12924a84924b096f3b401356805cc24593f4b800bab4ad05be06298size 1350import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, str, operators, Code} from "../../compile/codegen"
const ops = operators
type Kwd = "maximum" | "minimum" | "exclusiveMaximum" | "exclusiveMinimum"
type Comparison = "<=" | ">=" | "<" | ">"
const KWDs: {[K in Kwd]: {okStr: Comparison; ok: Code; fail: Code}} = { maximum: {okStr: "<=", ok: ops.LTE, fail: ops.GT}, minimum: {okStr: ">=", ok: ops.GTE, fail: ops.LT}, exclusiveMaximum: {okStr: "<", ok: ops.LT, fail: ops.GTE}, exclusiveMinimum: {okStr: ">", ok: ops.GT, fail: ops.LTE},}
export type LimitNumberError = ErrorObject< Kwd, {limit: number; comparison: Comparison}, number | {$data: string}>
const error: KeywordErrorDefinition = { message: ({keyword, schemaCode}) => str`must be ${KWDs[keyword as Kwd].okStr} ${schemaCode}`, params: ({keyword, schemaCode}) => _`{comparison: ${KWDs[keyword as Kwd].okStr}, limit: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: Object.keys(KWDs), type: "number", schemaType: "number", $data: true, error, code(cxt: KeywordCxt) { const {keyword, data, schemaCode} = cxt cxt.fail$data(_`${data} ${KWDs[keyword as Kwd].fail} ${schemaCode} || isNaN(${data})`) },}
export default def1231234567891011121314151617181920212223242526version https://git-lfs.github.com/spec/v1oid sha256:d55088c19cd829be5ff23dc7bb98dde9bb0bc9fb3baa2a4a141797044a668048size 851import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, str, operators} from "../../compile/codegen"
const error: KeywordErrorDefinition = { message({keyword, schemaCode}) { const comp = keyword === "maxProperties" ? "more" : "fewer" return str`must NOT have ${comp} than ${schemaCode} properties` }, params: ({schemaCode}) => _`{limit: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: ["maxProperties", "minProperties"], type: "object", schemaType: "number", $data: true, error, code(cxt: KeywordCxt) { const {keyword, data, schemaCode} = cxt const op = keyword === "maxProperties" ? operators.GT : operators.LT cxt.fail$data(_`Object.keys(${data}).length ${op} ${schemaCode}`) },}
export default def12312345678910111213141516171819202122232425262728293031323334version https://git-lfs.github.com/spec/v1oid sha256:5130cb4147d60dbec590b1e153f0f69b3c7ab552da9dd12eb2e1c22ca36daf7csize 1072import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {_, str} from "../../compile/codegen"
export type MultipleOfError = ErrorObject< "multipleOf", {multipleOf: number}, number | {$data: string}>
const error: KeywordErrorDefinition = { message: ({schemaCode}) => str`must be multiple of ${schemaCode}`, params: ({schemaCode}) => _`{multipleOf: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: "multipleOf", type: "number", schemaType: "number", $data: true, error, code(cxt: KeywordCxt) { const {gen, data, schemaCode, it} = cxt // const bdt = bad$DataType(schemaCode, <string>def.schemaType, $data) const prec = it.opts.multipleOfPrecision const res = gen.let("res") const invalid = prec ? _`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : _`${res} !== parseInt(${res})` cxt.fail$data(_`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`) },}
export default def12312345678910111213141516171819202122232425262728version https://git-lfs.github.com/spec/v1oid sha256:9bdea618249c43667c80c253f28ff36f97ddf02bdda63f8897f7764014c3b314size 961import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {usePattern} from "../code"import {_, str} from "../../compile/codegen"
export type PatternError = ErrorObject<"pattern", {pattern: string}, string | {$data: string}>
const error: KeywordErrorDefinition = { message: ({schemaCode}) => str`must match pattern "${schemaCode}"`, params: ({schemaCode}) => _`{pattern: ${schemaCode}}`,}
const def: CodeKeywordDefinition = { keyword: "pattern", type: "string", schemaType: "string", $data: true, error, code(cxt: KeywordCxt) { const {data, $data, schema, schemaCode, it} = cxt // TODO regexp should be wrapped in try/catchs const u = it.opts.unicodeRegExp ? "u" : "" const regExp = $data ? _`(new RegExp(${schemaCode}, ${u}))` : usePattern(cxt, schema) cxt.fail$data(_`!${regExp}.test(${data})`) },}
export default def1231234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798version https://git-lfs.github.com/spec/v1oid sha256:73f26a08d78ace7a164eca526843086bfbb986799d9a7ecc02fb67a87d2456aasize 2961import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import { checkReportMissingProp, checkMissingProp, reportMissingProp, propertyInData, noPropertyInData,} from "../code"import {_, str, nil, not, Name, Code} from "../../compile/codegen"import {checkStrictMode} from "../../compile/util"
export type RequiredError = ErrorObject< "required", {missingProperty: string}, string[] | {$data: string}>
const error: KeywordErrorDefinition = { message: ({params: {missingProperty}}) => str`must have required property '${missingProperty}'`, params: ({params: {missingProperty}}) => _`{missingProperty: ${missingProperty}}`,}
const def: CodeKeywordDefinition = { keyword: "required", type: "object", schemaType: "array", $data: true, error, code(cxt: KeywordCxt) { const {gen, schema, schemaCode, data, $data, it} = cxt const {opts} = it if (!$data && schema.length === 0) return const useLoop = schema.length >= opts.loopRequired if (it.allErrors) allErrorsMode() else exitOnErrorMode()
if (opts.strictRequired) { const props = cxt.parentSchema.properties const {definedProperties} = cxt.it for (const requiredKey of schema) { if (props?.[requiredKey] === undefined && !definedProperties.has(requiredKey)) { const schemaPath = it.schemaEnv.baseId + it.errSchemaPath const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)` checkStrictMode(it, msg, it.opts.strictRequired) } } }
function allErrorsMode(): void { if (useLoop || $data) { cxt.block$data(nil, loopAllRequired) } else { for (const prop of schema) { checkReportMissingProp(cxt, prop) } } }
function exitOnErrorMode(): void { const missing = gen.let("missing") if (useLoop || $data) { const valid = gen.let("valid", true) cxt.block$data(valid, () => loopUntilMissing(missing, valid)) cxt.ok(valid) } else { gen.if(checkMissingProp(cxt, schema, missing)) reportMissingProp(cxt, missing) gen.else() } }
function loopAllRequired(): void { gen.forOf("prop", schemaCode as Code, (prop) => { cxt.setParams({missingProperty: prop}) gen.if(noPropertyInData(gen, data, prop, opts.ownProperties), () => cxt.error()) }) }
function loopUntilMissing(missing: Name, valid: Name): void { cxt.setParams({missingProperty: missing}) gen.forOf( missing, schemaCode as Code, () => { gen.assign(valid, propertyInData(gen, data, missing, opts.ownProperties)) gen.if(not(valid), () => { cxt.error() gen.break() }) }, nil ) } },}
export default def12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879version https://git-lfs.github.com/spec/v1oid sha256:9d978fd6b3dc81c07c60f5067253490b54962571a4b510e18f4e257508809ee0size 2690import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"import type {KeywordCxt} from "../../compile/validate"import {checkDataTypes, getSchemaTypes, DataType} from "../../compile/validate/dataType"import {_, str, Name} from "../../compile/codegen"import {useFunc} from "../../compile/util"import equal from "../../runtime/equal"
export type UniqueItemsError = ErrorObject< "uniqueItems", {i: number; j: number}, boolean | {$data: string}>
const error: KeywordErrorDefinition = { message: ({params: {i, j}}) => str`must NOT have duplicate items (items ## ${j} and ${i} are identical)`, params: ({params: {i, j}}) => _`{i: ${i}, j: ${j}}`,}
const def: CodeKeywordDefinition = { keyword: "uniqueItems", type: "array", schemaType: "boolean", $data: true, error, code(cxt: KeywordCxt) { const {gen, data, $data, schema, parentSchema, schemaCode, it} = cxt if (!$data && !schema) return const valid = gen.let("valid") const itemTypes = parentSchema.items ? getSchemaTypes(parentSchema.items) : [] cxt.block$data(valid, validateUniqueItems, _`${schemaCode} === false`) cxt.ok(valid)
function validateUniqueItems(): void { const i = gen.let("i", _`${data}.length`) const j = gen.let("j") cxt.setParams({i, j}) gen.assign(valid, true) gen.if(_`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j)) }
function canOptimize(): boolean { return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array") }
function loopN(i: Name, j: Name): void { const item = gen.name("item") const wrongType = checkDataTypes(itemTypes, item, it.opts.strictNumbers, DataType.Wrong) const indices = gen.const("indices", _`{}`) gen.for(_`;${i}--;`, () => { gen.let(item, _`${data}[${i}]`) gen.if(wrongType, _`continue`) if (itemTypes.length > 1) gen.if(_`typeof ${item} == "string"`, _`${item} += "_"`) gen .if(_`typeof ${indices}[${item}] == "number"`, () => { gen.assign(j, _`${indices}[${item}]`) cxt.error() gen.assign(valid, false).break() }) .code(_`${indices}[${item}] = ${i}`) }) }
function loopN2(i: Name, j: Name): void { const eql = useFunc(gen, equal) const outer = gen.name("outer") gen.label(outer).for(_`;${i}--;`, () => gen.for(_`${j} = ${i}; ${j}--;`, () => gen.if(_`${eql}(${data}[${i}], ${data}[${j}])`, () => { cxt.error() gen.assign(valid, false).break(outer) }) ) ) } },}
export default def123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126version https://git-lfs.github.com/spec/v1oid sha256:d709d5b644116edb33f086f770bb3432f4705518b8a22b6769dc852566912dc1size 4457{ "name": "ajv", "version": "8.14.0", "description": "Another JSON Schema Validator", "main": "dist/ajv.js", "types": "dist/ajv.d.ts", "files": [ "lib/", "dist/", ".runkit_example.js" ], "scripts": { "eslint": "eslint \"lib/**/*.ts\" \"spec/**/*.*s\" --ignore-pattern spec/JSON-Schema-Test-Suite", "prettier:write": "prettier --write \"./**/*.{json,yaml,js,ts}\"", "prettier:check": "prettier --list-different \"./**/*.{json,yaml,js,ts}\"", "test-spec": "cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register \"spec/**/*.spec.{ts,js}\" -R dot", "test-codegen": "nyc cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register 'spec/codegen.spec.ts' -R spec", "test-debug": "npm run test-spec -- --inspect-brk", "test-cov": "nyc npm run test-spec", "rollup": "rm -rf bundle && rollup -c", "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", "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", "json-tests": "rm -rf spec/_json/*.js && node scripts/jsontests", "test-karma": "karma start", "test-browser": "rm -rf .browser && npm run bundle && scripts/prepare-tests && karma start", "test-all": "npm run test-cov && if-node-version 12 npm run test-browser", "test": "npm run json-tests && npm run prettier:check && npm run eslint && npm link && npm link --legacy-peer-deps ajv && npm run test-cov", "test-ci": "AJV_FULL_TEST=true npm test", "prepublish": "npm run build", "benchmark": "npm i && npm run build && npm link && cd ./benchmark && npm link --legacy-peer-deps ajv && npm i && node ./jtd", "docs:dev": "./scripts/prepare-site && vuepress dev docs", "docs:build": "./scripts/prepare-site && vuepress build docs" }, "nyc": { "exclude": [ "**/spec/**", "node_modules" ], "reporter": [ "lcov", "text-summary" ] }, "repository": "ajv-validator/ajv", "keywords": [ "JSON", "schema", "validator", "validation", "jsonschema", "json-schema", "json-schema-validator", "json-schema-validation" ], "author": "Evgeny Poberezkin", "license": "MIT", "bugs": "https://github.com/ajv-validator/ajv/issues", "homepage": "https://ajv.js.org", "runkitExampleFilename": ".runkit_example.js", "dependencies": { "fast-deep-equal": "^3.1.3", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2", "uri-js": "^4.4.1" }, "devDependencies": { "@ajv-validator/config": "^0.5.0", "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.6", "@types/chai": "^4.3.11", "@types/mocha": "^10.0.6", "@types/node": "^20.11.30", "@types/require-from-string": "^1.2.3", "@typescript-eslint/eslint-plugin": "^7.3.1", "@typescript-eslint/parser": "^7.3.1", "ajv-formats": "^3.0.1", "browserify": "^17.0.0", "chai": "^4.4.1", "cross-env": "^7.0.3", "dayjs": "^1.11.10", "dayjs-plugin-utc": "^0.1.2", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "fast-uri": "^2.3.0", "glob": "^10.3.10", "husky": "^9.0.11", "if-node-version": "^1.1.1", "jimp": "^0.22.10", "js-beautify": "^1.15.1", "json-schema-test": "^2.0.0", "karma": "^6.4.2", "karma-chrome-launcher": "^3.2.0", "karma-mocha": "^2.0.1", "lint-staged": "^15.2.2", "mocha": "^10.3.0", "module-from-string": "^3.3.0", "node-fetch": "^3.3.2", "nyc": "^15.1.0", "prettier": "3.0.3", "re2": "^1.20.9", "rollup": "^2.79.1", "rollup-plugin-terser": "^7.0.2", "ts-node": "^10.9.2", "tsify": "^5.0.4", "typescript": "5.3.3" }, "collective": { "type": "opencollective", "url": "https://opencollective.com/ajv" }, "funding": { "type": "github", "url": "https://github.com/sponsors/epoberezkin" }, "prettier": "@ajv-validator/config/prettierrc.json", "husky": { "hooks": { "pre-commit": "lint-staged && npm test" } }, "lint-staged": { "*.{json,yaml,js,ts}": "prettier --write" }}123123456789101112131415version https://git-lfs.github.com/spec/v1oid sha256:5a3b0007c4203f10fe11b3fe8747253eb994f135e10b73e1f88ada941af09c6esize 784The ISC License
Copyright (c) 2019 Elan Shanker, Paul Miller (https://paulmillr.com)
Permission to use, copy, modify, and/or distribute this software for anypurpose with or without fee is hereby granted, provided that the abovecopyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ORIN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/LICENSE+22-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/README.md+207-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/core/id.ts+10-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/core/index.ts+16-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/core/ref.ts+129-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/discriminator/index.ts+113-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/discriminator/types.ts+12-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/draft2020.ts+23-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/draft7.ts+17-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/dynamicAnchor.ts+31-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/dynamicRef.ts+51-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/index.ts+9-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/recursiveAnchor.ts+14-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/dynamic/recursiveRef.ts+10-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/errors.ts+18-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/format/format.ts+120-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/format/index.ts+6-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts+89-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/elements.ts+32-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/enum.ts+45-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/error.ts+23-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/index.ts+37-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/metadata.ts+24-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/nullable.ts+21-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts+15-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/properties.ts+184-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/ref.ts+76-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/type.ts+75-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/union.ts+12-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/jtd/values.ts+58-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/metadata.ts+17-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/next.ts+8-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/unevaluated/index.ts+7-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts+47-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts+85-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/const.ts+28-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/dependentRequired.ts+23-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/enum.ts+54-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/index.ts+49-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitContains.ts+16-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitItems.ts+26-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitLength.ts+30-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitNumber.ts+42-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts+26-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/multipleOf.ts+34-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/pattern.ts+28-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/required.ts+98-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/lib/vocabularies/validation/uniqueItems.ts+79-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/ajv/package.json+126-3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/anymatch/LICENSE+15-3