<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)
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
[![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin)
## Please [sponsor Ajv](https://github.com/sponsors/epoberezkin)
Dear Ajv users! â¤ï¸
I ask you to support the development of Ajv with donations. ð
Since 2015 Ajv has become widely used, thanks to your help and contributions:
- **90** contributors ð
- **5,000** dependent npm packages âï¸
- **7,000** github stars, from GitHub users [all over the world](https://www.google.com/maps/d/u/0/viewer?mid=1MGRV8ciFUGIbO1l0EKFWNJGYE7iSkDxP&ll=-3.81666561775622e-14%2C4.821737100000007&z=2) âï¸
- **5,000,000** dependent repositories on GitHub ð
- **120,000,000** npm downloads per month! ð¯
Your donations will fund futher development - small and large improvements, support of the next versions of JSON Schema specification, and, possibly, the code should be migrated to TypeScript to make it more maintainable.
I will greatly appreciate anything you can help with to make it happen:
- a **personal** donation - from $2 âï¸
- your **company** donation - from $10 ð
- a **sponsorship** to get promoted on Ajv or related packages - from $50 ð°
- an **introduction** to a sponsor who would benefit from the promotion on Ajv page ð¤
| Please [make donations via my GitHub sponsors page](https://github.com/sponsors/epoberezkin)<br>â¼ï¸ **GitHub will DOUBLE them** â¼ï¸ |
|---|
#### 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>
## 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)
- [ReDoS attack](#redos-attack)
- 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
萍萍学姐
- 粉丝: 2354
- 资源: 731
最新资源
- WebSocket详解-TCP全双工通信协议的工作原理与应用
- 信捷xdm plc三轴可编程运动控制程序,支持信捷XDM系列PLC ?信捷TG765触摸屏 支持直线插补 ,圆弧插补,延时,等待输入ON,等待输入OFF,执行输出ON,执行输出O
- Qt+OpenCV图像视觉框架全套源码上位机 工具可扩展 除了opencv和相机sdk的dll,其它所有算法均无封装,可以根据自己需要补充自己的工具 基于 Qt5.12.12 + VS2019 +
- 自动驾驶控制器,自动驾驶多传感器联合标定系列之毫米波雷达到车体坐标系的标定工程 , 本对毫米波雷达的偏航角yaw进行标定,分为粗略标定、静态目标识别和曲线拟合三个步骤 这个工程带有代码注释,帮助您
- 模块化多电平流器MMC,最近电平逼近调制+电压均衡控制
- 基于STM32开发的智能光控窗帘项目 主控芯片STM32F103. 其他控制:光敏电阻,1602显示屏,电机驱动控制模块 工作原理:ADC采集光敏电阻电压 判断电压值,对光照强度判断,光照太强关闭
- simulink二次调频风机储能水轮机水电火电汽轮机二次调频,有随机扰动负荷,可连续波动,可对频率分频调频,分低频,中频,高频,也可对不同死区的风储同步机进行二次调频,系统示意图和波形如图所示,新品
- 磁链观测器 vesc中使用的方法 已经移植到了自己的工程中,实现0速闭环启动 代码、文档、仿真是一一对应的,方便学习 送仿真模型
- uvw对位平台,XXY,XYθ对位平台源码,halcon定位算法,C#联合halcon,含C#和halcon源码,开发平台,vs2015,halcon17
- 考虑源荷不确定性的热电联供微网优化 复现《含可再生能源的热电联供型微网经济运行优化》,采用粒子群算法,采用机会约束规划理论出力源荷不确定性,采用概率方法来表达,目标函数代码完美复刻了文献中的目标函数和
- Python 实现的 TCN(时间卷积网络)进行多特征分类预测的详细实例(含完整的程序,GUI设计和代码详解)
- 基于EKF扩展卡尔曼滤波算法的永磁同步电机PMSM无传感器矢量控制Simulink仿真模型 1.依据PMSM的数学模型搭建电机模型 2.双闭环dq解耦控制,转速外环,转矩内环 3. EKF算法对电机
- Python 实现的 CNN-LSTM(卷积长短期记忆网络)用于时间序列预测的详细实例(含完整的程序,GUI设计和代码详解)
- 下垂控制三相LCL并网 离网matlab仿真模型(户用型储能逆变器)孤网运行联网运行 多机 单机运行 参数计算 仿真模型 ,逆变器,微电网
- Python 实现遗传算法(GA)和(PSO)粒子群优化算法来优化反向传播(BP)神经网络的多输入单输出预测的实例(含完整的程序,GUI设计和代码详解)
- 电子竞技信息交流平台+ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈