<img align="right" alt="Ajv logo" width="160" src="http://epoberezkin.github.io/ajv/images/ajv_logo.png">
# Ajv: Another JSON Schema Validator
The fastest JSON Schema validator for Node.js and browser. Supports draft-04/06/07.
[![Build Status](https://travis-ci.org/epoberezkin/ajv.svg?branch=master)](https://travis-ci.org/epoberezkin/ajv)
[![npm](https://img.shields.io/npm/v/ajv.svg)](https://www.npmjs.com/package/ajv)
[![npm downloads](https://img.shields.io/npm/dm/ajv.svg)](https://www.npmjs.com/package/ajv)
[![Coverage Status](https://coveralls.io/repos/epoberezkin/ajv/badge.svg?branch=master&service=github)](https://coveralls.io/github/epoberezkin/ajv?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/epoberezkin/ajv.svg)](https://greenkeeper.io/)
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
## Using version 6
[JSON Schema draft-07](http://json-schema.org/latest/json-schema-validation.html) is published.
[Ajv version 6.0.0](https://github.com/epoberezkin/ajv/releases/tag/v6.0.0) that supports draft-07 is released. It may require either migrating your schemas or updating your code (to continue using draft-04 and v5 schemas, draft-06 schemas will be supported without changes).
__Please note__: To use Ajv with draft-06 schemas you need to explicitly add the meta-schema to the validator instance:
```javascript
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));
```
To use Ajv with draft-04 schemas in addition to explicitly adding meta-schema you also need to use option schemaId:
```javascript
var ajv = new Ajv({schemaId: 'id'});
// If you want to use both draft-04 and draft-06/07 schemas:
// var ajv = new Ajv({schemaId: 'auto'});
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
```
## Contents
- [Performance](#performance)
- [Features](#features)
- [Getting started](#getting-started)
- [Frequently Asked Questions](https://github.com/epoberezkin/ajv/blob/master/FAQ.md)
- [Using in browser](#using-in-browser)
- [Command line interface](#command-line-interface)
- Validation
- [Keywords](#validation-keywords)
- [Annotation keywords](#annotation-keywords)
- [Formats](#formats)
- [Combining schemas with $ref](#ref)
- [$data reference](#data-reference)
- NEW: [$merge and $patch keywords](#merge-and-patch-keywords)
- [Defining custom keywords](#defining-custom-keywords)
- [Asynchronous schema compilation](#asynchronous-schema-compilation)
- [Asynchronous validation](#asynchronous-validation)
- [Security considerations](#security-considerations)
- [Security contact](#security-contact)
- [Untrusted schemas](#untrusted-schemas)
- [Circular references in objects](#circular-references-in-javascript-objects)
- [Trusted schemas](#security-risks-of-trusted-schemas)
- Modifying data during validation
- [Filtering data](#filtering-data)
- [Assigning defaults](#assigning-defaults)
- [Coercing data types](#coercing-data-types)
- API
- [Methods](#api)
- [Options](#options)
- [Validation errors](#validation-errors)
- [Plugins](#plugins)
- [Related packages](#related-packages)
- [Some packages using Ajv](#some-packages-using-ajv)
- [Tests, Contributing, History, Support, License](#tests)
## Performance
Ajv generates code using [doT templates](https://github.com/olado/doT) to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.
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):
[![performance](https://chart.googleapis.com/chart?chxt=x,y&cht=bhs&chco=76A4FB&chls=2.0&chbh=32,4,1&chs=600x416&chxl=-1:|djv|ajv|json-schema-validator-generator|jsen|is-my-json-valid|themis|z-schema|jsck|skeemas|json-schema-library|tv4&chd=t:100,98,72.1,66.8,50.1,15.1,6.1,3.8,1.2,0.7,0.2)](https://github.com/ebdrup/json-schema-benchmark/blob/master/README.md#performance)
## Features
- Ajv implements full JSON Schema [draft-06/07](http://json-schema.org/) and draft-04 standards:
- all validation keywords (see [JSON Schema validation keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md))
- full support of remote refs (remote schemas have to be added with `addSchema` or compiled to be available)
- support of circular references between schemas
- correct string lengths for strings with unicode pairs (can be turned off)
- [formats](#formats) defined by JSON Schema draft-07 standard and custom formats (can be turned off)
- [validates schemas against meta-schema](#api-validateschema)
- supports [browsers](#using-in-browser) and Node.js 0.10-8.x
- [asynchronous loading](#asynchronous-schema-compilation) of referenced schemas during compilation
- "All errors" validation mode with [option allErrors](#options)
- [error messages with parameters](#validation-errors) describing error reasons to allow creating custom error messages
- i18n error messages support with [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) package
- [filtering data](#filtering-data) from additional properties
- [assigning defaults](#assigning-defaults) to missing properties and items
- [coercing data](#coercing-data-types) to the types specified in `type` keywords
- [custom keywords](#defining-custom-keywords)
- draft-06/07 keywords `const`, `contains`, `propertyNames` and `if/then/else`
- draft-06 boolean schemas (`true`/`false` as a schema to always pass/fail).
- keywords `switch`, `patternRequired`, `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum` from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) with [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package
- [$data reference](#data-reference) to use values from the validated data as values for the schema keywords
- [asynchronous validation](#asynchronous-validation) of custom formats and keywords
Currently Ajv is the only validator that passes all the tests from [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) (according to [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark), apart from the test that requires that `1.0` is not an integer that is impossible to satisfy in JavaScript).
## Install
```
npm install ajv
```
## <a name="usage"></a>Getting started
Try it in the Node.js REPL: https://tonicdev.com/npm/ajv
The fastest validation call:
```javascript
var Ajv = require('ajv');
var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true}
var validate = ajv.compile(schema);
var valid = validate(data);
if (!valid) console.log(validate.errors);
```
or with less code
```javascript
// ...
var valid = ajv.validate(schema, data);
if (!valid) console.log(ajv.errors);
// ...
```
or
```javascript
// ...
var valid = ajv.addSchema(schema, 'mySchema')
.validate('mySchema', data);
if (!valid) console.log(ajv.errorsText());
// ...
```
See [API](#api) and [Options](#options) for more details.
Ajv compiles schemas to functions and caches them in all cases (using schema serialized with [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) or a custom function as a key), so that the next time the same schema is used (not necessarily the same object instance) it won't be compiled again.
The best performance is achieved when using compiled functions returned by `compile` or `getSchema` methods (there i
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
校园服务类小程序,开放功能有二手市场,代取快递,失物招领,老乡群,校内各部门电话,校内地图查询等等。源码详细,即可使用。 【限时开放 | 免费下载 | 截止7月1日】「校园服务小程序.exe」https://www.aliyundrive.com/s/T4s2tPs5Phe 提取码: l71w 点击链接保存,或者复制本段内容,打开「阿里云盘」APP . 双击exe文件自动解压。
资源推荐
资源详情
资源评论
收起资源包目录
校园服务类小程序源码.zip (1654个子文件)
005f676664747edfc5917a57e991e3f18ac21b 545B
00687274b939c6042142efd2a45ac7c02317fb 155B
00d3046422d7a778d94390271e2d8d3214546b 223B
0136df0b8310a211713a340c840318a271d6f8 373B
01f6b3d10f0a497117d7ab761a70b91a8f5a35 58B
02add20b581be471b8d17f887b8e8337070546 194B
04f5bc9f6033ce792e65eab8db9bf5c765dceb 381B
055103dd4ba98ab32c286da4cc3202f12a9e04 891B
05da0129bae7180a196e9ee80172d437eb6040 2KB
08194a11a37f72cf8ee74f9537876f2ef38e70 269B
0b56b2a84bf344f09c380737f6b3ffc8695d52 79B
0c48c551e336c3bee44131b88a5eb7f0870df3 374B
0e1c1237be1f8183c20bba0ec6c663cffb3802 1KB
sshpk-conv.1 4KB
sshpk-sign.1 2KB
sshpk-verify.1 2KB
1056618c22676a36e3fe7f22e84ec2e3e0d64e 645B
11cea5dd06c73c2a34f40e8f2f9ce0c062070e 488B
128c7eca52071ca160057c1d79c0665fd14fa1 9KB
13cd42ade81ec6b750e2f1102bd3769a60cf66 5KB
1452946f2cff8bf7c3fa9f6d00e5299e1a6483 30KB
15a934cdee3049b5b2ed0cc4c1851118da089e 42B
16e6f41e63b59e2394d066c419094b52c8692d 403B
1c438bd20a5575927d9d4bd39e07db5e8c2c45 165B
1f1ee84a808312d658b7a9a6c67d7a4f47637b 135B
20b6fabbb930fc6227191825dfb9eed5c81369 5KB
221b4222e42b54e1a11af84d20b23ec9337a4d 588B
2342bc00e8f3793dcbc6776db83aadc2dc3afd 226B
2397d7b817a083b4ae5348bee76dd8041f07c8 591B
23ac903aed92dfc7b3ee8de3bd3e3f3f537f03 283B
24e31f820e0b25283b3167f5f31b36701df12a 9KB
27b385c3056b7b0c345b51c68ad1ce745eaeee 674B
291ea6dfcf69920fccc3214a54f8d6a574d6fc 225B
29931c8c9c0b2cd3551752f5f29cef121a95e7 2KB
3197ae2baa4775b179ffd41f627d9a68b90223 168B
359ca9ed574ad5133fbe4260c4c7e18a493310 112B
35af0699ccec004cbe685ef938cd2d63ea7037 43B
3708ceefb52d4a6ca3ce298ff58fc831f1b273 6KB
3782354bf41a390cca569fc3d81ac01cc70101 555B
38e53920d79db39a4e663ae40baaa51657a674 589B
39461f33d75dea3c546d8cb5565cb83d7a0213 184B
39943df3a3489c433d663c23694184325a273c 545B
39a1699835659827a751256c84a296af2a3ff0 137B
39cd4f1d29e84191402ab51760c292efaa2df5 706B
3c0ccb513871e443aef720fc48f5ea426b807f 137B
3d5ddd6e1e5b3ce2c9ec830f7367372a9f8e69 274B
3e193f5755009a23d086498ca82bafb73b6800 565B
4269688902a21c19f8f8796fc3aaf7c4611750 156B
45bccd7c7839bf8e24ddcf2648b8b7f96b16e0 11KB
465a1c44773179841dae01ec82469855ed9fec 18KB
468d4eb7adc83def5f41f20a056f884c5d5452 10KB
49fdba3e109fa0601af446d4b284082bedee61 208B
4ad513566693e86a19ae64ae7ee7a24b1d9ea2 776B
4ad9c1fba912cb664f1d1c5f80f9e51d6f44b1 624B
4cb6e3861b671c9033726b6c12bdb0f3031348 59KB
4e0be8721f43df8d059c9b957f1b4a8489c2b1 2KB
51458764affdc19538c004640dacb2f3002ec8 40B
52b2375a37e8ef19aca41709768724c5889cd4 319B
543544356e530b47fbeb0872ed528430b8b724 474B
5797c1522d4d8397eb2ec4b5d1d9efe7eeb116 12KB
5927ef4421839b5c4a318708762c4ae7667c3e 275B
5c7a58672e1a92d81cab9f09d7a3b6611c932e 4KB
5c9f6af5c1938f49f44659a623f3f267dc5b9f 512B
5e125358ebc4ab85a96291bd987936229de57a 90B
5e229daf46fd13d115ef84d632166e805aa43b 7KB
640f0fd75edad695a68a20fef4f0ac04fa089d 10KB
660cac86d31364f1384f730fb2aeedc261fdb4 133B
66519e4af192ac8e41ca5ba2eebf56e0124832 362B
67ef60a0acc53381107975a0a85d39f271e25b 120B
68f290a32f503662b72989d19bb7a6729c739c 667B
6bb888913c1ee628e3d14b9fdddc1cb7254b48 54B
6c73bdb38c0ee267cf1dc4ae2b19da3324f0ee 347B
70e6a778bf67e1222c7cf377a11482d94e39c6 3KB
74872bbab44f60144c8541c1bdd6cd139c6207 8KB
7583e8b43c4efb1b0a0973b9dbfb01ec852ce1 6KB
761f8342088931cf3a3db4c24a6b81fa588131 3KB
76821de626a134303f16467ef568a965add8ca 159B
770b1447fb21727d7e43218fb76755460166e9 189KB
77414ee1de65244098b2cf8d215547e1318b0e 702B
775e657286201f1bc78b9e85234e8472ac83d7 457B
7acf53ef186d07094c7b4fd162b87205646c61 9KB
7d6c2c9c2cad8b3e14f2961129e1e51b959ea3 51B
849a24d88f77daff798a633fe0dc5f400eacbc 377B
849ae354a03ed5d06475c8ef42c238cbd36389 1KB
8550d90efd924570e535bc1d3f2225581031d7 134KB
859a6e983f450e24416162d37076051cc1e5cc 199B
85eb03db6d6a274a8bf0bf7182acd07c40c3e6 128B
8779d287830b97cb504ba44946185bb898e8e4 168B
87b69e1adfa9d317f52f5171e8baae21c1b6a7 497B
884eb6b02bdd42ad8cbed11941c9927dfebd3a 8KB
88626006c2f906aadb5f8461b45162ace9628e 206B
89b548f62a299c75ecb4c388b30816f286304a 52B
8a0592177d25cd9bf016eed4acbb336ca2ff26 120B
8a192e2ddc92270f42509f4ceb689f2b1e1f5e 78B
8aa450878ff1755e30fe40896417070a134006 168B
8c20a2abfde0de2187a5b2a44d2e71169eb2d9 539B
8d12ccdfc074f55a60064b6fb3e658c05b6917 65B
8ed163840b694b8bf089ab111e6b6fa8aeb066 53B
92bc48de489824055f27356dfb5ccaa10ec30b 561B
934b13ee58b5376b5321258eb581e4fac90364 6KB
共 1654 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
- zxg452020-12-04适用于初学者,要求技术不是很高,功能比较全面
- 洲ᝰ洋2020-08-18不是php,没有引导教程
zxg45
- 粉丝: 6574
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 矩阵式键盘按键值的数码管显示实验_单片机C语言实例(纯C语言源代码).zip
- NKUMachineLearning-lab2.1-线性logistics分类
- Pycharm-Python爬虫专业工具 我的最爱使用
- Wireshark-4.2.4-x64.exe
- Video DownloadHelper需要的合作应用VdhCoApp 2.0.19
- Screenshot_2024-04-20-16-26-41-628_com.tencent.mm-edit.jpg
- 基于python+YOLOV7与DeepLabv3+图像深度学习算法+车载摄像头道路识别+语音告知车道偏离、前后方车距等辅助驾驶
- SpringBoot项目2.6.6版本基础框架
- CursorAI编程和软件开发.txt
- C语言编写的学生管理系统,由多个 .c 文件和 .h文件组成 我用的是VSCode软件编写的
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功