172 lines
78 KiB
JSON
172 lines
78 KiB
JSON
{
|
||
"_args": [
|
||
[
|
||
{
|
||
"raw": "ajv@^5.1.0",
|
||
"scope": null,
|
||
"escapedName": "ajv",
|
||
"name": "ajv",
|
||
"rawSpec": "^5.1.0",
|
||
"spec": ">=5.1.0 <6.0.0",
|
||
"type": "range"
|
||
},
|
||
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/har-validator"
|
||
]
|
||
],
|
||
"_from": "ajv@>=5.1.0 <6.0.0",
|
||
"_id": "ajv@5.5.2",
|
||
"_inCache": true,
|
||
"_location": "/ajv",
|
||
"_nodeVersion": "6.9.1",
|
||
"_npmOperationalInternal": {
|
||
"host": "s3://npm-registry-packages",
|
||
"tmp": "tmp/ajv-5.5.2.tgz_1513456518424_0.9640620034188032"
|
||
},
|
||
"_npmUser": {
|
||
"name": "esp",
|
||
"email": "e.poberezkin@me.com"
|
||
},
|
||
"_npmVersion": "3.10.8",
|
||
"_phantomChildren": {},
|
||
"_requested": {
|
||
"raw": "ajv@^5.1.0",
|
||
"scope": null,
|
||
"escapedName": "ajv",
|
||
"name": "ajv",
|
||
"rawSpec": "^5.1.0",
|
||
"spec": ">=5.1.0 <6.0.0",
|
||
"type": "range"
|
||
},
|
||
"_requiredBy": [
|
||
"/@expo/schemer",
|
||
"/har-validator"
|
||
],
|
||
"_resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
|
||
"_shasum": "73b5eeca3fab653e3d3f9422b341ad42205dc965",
|
||
"_shrinkwrap": null,
|
||
"_spec": "ajv@^5.1.0",
|
||
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/har-validator",
|
||
"author": {
|
||
"name": "Evgeny Poberezkin"
|
||
},
|
||
"bugs": {
|
||
"url": "https://github.com/epoberezkin/ajv/issues"
|
||
},
|
||
"dependencies": {
|
||
"co": "^4.6.0",
|
||
"fast-deep-equal": "^1.0.0",
|
||
"fast-json-stable-stringify": "^2.0.0",
|
||
"json-schema-traverse": "^0.3.0"
|
||
},
|
||
"description": "Another JSON Schema Validator",
|
||
"devDependencies": {
|
||
"ajv-async": "^0.1.0",
|
||
"bluebird": "^3.1.5",
|
||
"brfs": "^1.4.3",
|
||
"browserify": "^14.1.0",
|
||
"chai": "^4.0.1",
|
||
"coveralls": "^3.0.0",
|
||
"del-cli": "^1.1.0",
|
||
"dot": "^1.0.3",
|
||
"eslint": "^4.1.0",
|
||
"gh-pages-generator": "^0.2.0",
|
||
"glob": "^7.0.0",
|
||
"if-node-version": "^1.0.0",
|
||
"js-beautify": "^1.7.3",
|
||
"jshint": "^2.9.4",
|
||
"json-schema-test": "^2.0.0",
|
||
"karma": "^1.0.0",
|
||
"karma-chrome-launcher": "^2.0.0",
|
||
"karma-mocha": "^1.1.1",
|
||
"karma-phantomjs-launcher": "^1.0.0",
|
||
"karma-sauce-launcher": "^1.1.0",
|
||
"mocha": "^4.0.0",
|
||
"nodent": "^3.0.17",
|
||
"nyc": "^11.0.2",
|
||
"phantomjs-prebuilt": "^2.1.4",
|
||
"pre-commit": "^1.1.1",
|
||
"regenerator": "^0.12.2",
|
||
"require-globify": "^1.3.0",
|
||
"typescript": "^2.6.2",
|
||
"uglify-js": "^3.1.5",
|
||
"watch": "^1.0.0"
|
||
},
|
||
"directories": {},
|
||
"dist": {
|
||
"shasum": "73b5eeca3fab653e3d3f9422b341ad42205dc965",
|
||
"tarball": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz"
|
||
},
|
||
"files": [
|
||
"lib/",
|
||
"dist/",
|
||
"scripts/",
|
||
"LICENSE",
|
||
".tonic_example.js"
|
||
],
|
||
"gitHead": "cecd4ecca66abee0441a8277c647856b09454f82",
|
||
"homepage": "https://github.com/epoberezkin/ajv",
|
||
"keywords": [
|
||
"JSON",
|
||
"schema",
|
||
"validator",
|
||
"validation",
|
||
"jsonschema",
|
||
"json-schema",
|
||
"json-schema-validator",
|
||
"json-schema-validation"
|
||
],
|
||
"license": "MIT",
|
||
"main": "lib/ajv.js",
|
||
"maintainers": [
|
||
{
|
||
"name": "blakeembrey",
|
||
"email": "hello@blakeembrey.com"
|
||
},
|
||
{
|
||
"name": "esp",
|
||
"email": "e.poberezkin@me.com"
|
||
}
|
||
],
|
||
"name": "ajv",
|
||
"nyc": {
|
||
"exclude": [
|
||
"**/spec/**",
|
||
"node_modules"
|
||
],
|
||
"reporter": [
|
||
"lcov",
|
||
"text-summary"
|
||
]
|
||
},
|
||
"optionalDependencies": {},
|
||
"readme": "<img align=\"right\" alt=\"Ajv logo\" width=\"160\" src=\"http://epoberezkin.github.io/ajv/images/ajv_logo.png\">\n\n# Ajv: Another JSON Schema Validator\n\nThe fastest JSON Schema validator for Node.js and browser with draft 6 support.\n\n\n[![Build Status](https://travis-ci.org/epoberezkin/ajv.svg?branch=master)](https://travis-ci.org/epoberezkin/ajv)\n[![npm version](https://badge.fury.io/js/ajv.svg)](https://www.npmjs.com/package/ajv)\n[![npm@beta](https://img.shields.io/npm/v/ajv/beta.svg)](https://github.com/epoberezkin/ajv/tree/beta)\n[![npm downloads](https://img.shields.io/npm/dm/ajv.svg)](https://www.npmjs.com/package/ajv)\n[![Coverage Status](https://coveralls.io/repos/epoberezkin/ajv/badge.svg?branch=master&service=github)](https://coveralls.io/github/epoberezkin/ajv?branch=master)\n[![Greenkeeper badge](https://badges.greenkeeper.io/epoberezkin/ajv.svg)](https://greenkeeper.io/)\n[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)\n\n\n__Please note__: Ajv [version 6](https://github.com/epoberezkin/ajv/tree/beta) with [JSON Schema draft-07](http://json-schema.org/work-in-progress) support is released. Use `npm install ajv@beta` to install.\n\n\n## Using version 5\n\n[JSON Schema draft-06](https://trac.tools.ietf.org/html/draft-wright-json-schema-validation-01) is published.\n\n[Ajv version 5.0.0](https://github.com/epoberezkin/ajv/releases/tag/5.0.0) that supports draft-06 is released. It may require either migrating your schemas or updating your code (to continue using draft-04 and v5 schemas).\n\n__Please note__: To use Ajv with draft-04 schemas you need to explicitly add meta-schema to the validator instance:\n\n```javascript\najv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));\n```\n\n\n## Contents\n\n- [Performance](#performance)\n- [Features](#features)\n- [Getting started](#getting-started)\n- [Frequently Asked Questions](https://github.com/epoberezkin/ajv/blob/master/FAQ.md)\n- [Using in browser](#using-in-browser)\n- [Command line interface](#command-line-interface)\n- Validation\n - [Keywords](#validation-keywords)\n - [Formats](#formats)\n - [Combining schemas with $ref](#ref)\n - [$data reference](#data-reference)\n - NEW: [$merge and $patch keywords](#merge-and-patch-keywords)\n - [Defining custom keywords](#defining-custom-keywords)\n - [Asynchronous schema compilation](#asynchronous-schema-compilation)\n - [Asynchronous validation](#asynchronous-validation)\n- Modifying data during validation\n - [Filtering data](#filtering-data)\n - [Assigning defaults](#assigning-defaults)\n - [Coercing data types](#coercing-data-types)\n- API\n - [Methods](#api)\n - [Options](#options)\n - [Validation errors](#validation-errors)\n- [Related packages](#related-packages)\n- [Packages using Ajv](#some-packages-using-ajv)\n- [Tests, Contributing, History, License](#tests)\n\n\n## Performance\n\nAjv 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.\n\nCurrently Ajv is the fastest and the most standard compliant validator according to these benchmarks:\n\n- [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark) - 50% faster than the second place\n- [jsck benchmark](https://github.com/pandastrike/jsck#benchmarks) - 20-190% faster\n- [z-schema benchmark](https://rawgit.com/zaggino/z-schema/master/benchmark/results.html)\n- [themis benchmark](https://cdn.rawgit.com/playlyfe/themis/master/benchmark/results.html)\n\n\nPerformance of different validators by [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark):\n\n[![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)\n\n\n## Features\n\n- Ajv implements full JSON Schema [draft 6](http://json-schema.org/) and draft 4 standards:\n - all validation keywords (see [JSON Schema validation keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md))\n - full support of remote refs (remote schemas have to be added with `addSchema` or compiled to be available)\n - support of circular references between schemas\n - correct string lengths for strings with unicode pairs (can be turned off)\n - [formats](#formats) defined by JSON Schema draft 4 standard and custom formats (can be turned off)\n - [validates schemas against meta-schema](#api-validateschema)\n- supports [browsers](#using-in-browser) and Node.js 0.10-8.x\n- [asynchronous loading](#asynchronous-schema-compilation) of referenced schemas during compilation\n- \"All errors\" validation mode with [option allErrors](#options)\n- [error messages with parameters](#validation-errors) describing error reasons to allow creating custom error messages\n- i18n error messages support with [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) package\n- [filtering data](#filtering-data) from additional properties\n- [assigning defaults](#assigning-defaults) to missing properties and items\n- [coercing data](#coercing-data-types) to the types specified in `type` keywords\n- [custom keywords](#defining-custom-keywords)\n- draft-6 keywords `const`, `contains` and `propertyNames`\n- draft-6 boolean schemas (`true`/`false` as a schema to always pass/fail).\n- 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\n- [$data reference](#data-reference) to use values from the validated data as values for the schema keywords\n- [asynchronous validation](#asynchronous-validation) of custom formats and keywords\n\nCurrently 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).\n\n\n## Install\n\n```\nnpm install ajv\n```\n\nor to install [version 6](https://github.com/epoberezkin/ajv/tree/beta):\n\n```\nnpm install ajv@beta\n```\n\n\n## <a name=\"usage\"></a>Getting started\n\nTry it in the Node.js REPL: https://tonicdev.com/npm/ajv\n\n\nThe fastest validation call:\n\n```javascript\nvar Ajv = require('ajv');\nvar ajv = new Ajv(); // options can be passed, e.g. {allErrors: true}\nvar validate = ajv.compile(schema);\nvar valid = validate(data);\nif (!valid) console.log(validate.errors);\n```\n\nor with less code\n\n```javascript\n// ...\nvar valid = ajv.validate(schema, data);\nif (!valid) console.log(ajv.errors);\n// ...\n```\n\nor\n\n```javascript\n// ...\nvar valid = ajv.addSchema(schema, 'mySchema')\n .validate('mySchema', data);\nif (!valid) console.log(ajv.errorsText());\n// ...\n```\n\nSee [API](#api) and [Options](#options) for more details.\n\nAjv 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.\n\nThe best performance is achieved when using compiled functions returned by `compile` or `getSchema` methods (there is no additional function call).\n\n__Please note__: every time a validation function or `ajv.validate` are called `errors` property is overwritten. You need to copy `errors` array reference to another variable if you want to use it later (e.g., in the callback). See [Validation errors](#validation-errors)\n\n\n## Using in browser\n\nYou can require Ajv directly from the code you browserify - in this case Ajv will be a part of your bundle.\n\nIf you need to use Ajv in several bundles you can create a separate UMD bundle using `npm run bundle` script (thanks to [siddo420](https://github.com/siddo420)).\n\nThen you need to load Ajv in the browser:\n```html\n<script src=\"ajv.min.js\"></script>\n```\n\nThis bundle can be used with different module systems; it creates global `Ajv` if no module system is found.\n\nThe browser bundle is available on [cdnjs](https://cdnjs.com/libraries/ajv).\n\nAjv is tested with these browsers:\n\n[![Sauce Test Status](https://saucelabs.com/browser-matrix/epoberezkin.svg)](https://saucelabs.com/u/epoberezkin)\n\n__Please note__: some frameworks, e.g. Dojo, may redefine global require in such way that is not compatible with CommonJS module format. In such case Ajv bundle has to be loaded before the framework and then you can use global Ajv (see issue [#234](https://github.com/epoberezkin/ajv/issues/234)).\n\n\n## Command line interface\n\nCLI is available as a separate npm package [ajv-cli](https://github.com/jessedc/ajv-cli). It supports:\n\n- compiling JSON-schemas to test their validity\n- BETA: generating standalone module exporting a validation function to be used without Ajv (using [ajv-pack](https://github.com/epoberezkin/ajv-pack))\n- migrate schemas to draft-06 (using [json-schema-migrate](https://github.com/epoberezkin/json-schema-migrate))\n- validating data file(s) against JSON-schema\n- testing expected validity of data against JSON-schema\n- referenced schemas\n- custom meta-schemas\n- files in JSON and JavaScript format\n- all Ajv options\n- reporting changes in data after validation in [JSON-patch](https://tools.ietf.org/html/rfc6902) format\n\n\n## Validation keywords\n\nAjv supports all validation keywords from draft 4 of JSON-schema standard:\n\n- [type](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#type)\n- [for numbers](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-numbers) - maximum, minimum, exclusiveMaximum, exclusiveMinimum, multipleOf\n- [for strings](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-strings) - maxLength, minLength, pattern, format\n- [for arrays](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-arrays) - maxItems, minItems, uniqueItems, items, additionalItems, [contains](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#contains)\n- [for objects](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-objects) - maxProperties, minProperties, required, properties, patternProperties, additionalProperties, dependencies, [propertyNames](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#propertynames)\n- [for all types](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-all-types) - enum, [const](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#const)\n- [compound keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#compound-keywords) - not, oneOf, anyOf, allOf\n\nWith [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package Ajv also supports validation keywords from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) for JSON-schema standard:\n\n- [switch](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#switch-proposed) - conditional validation with a sequence of if/then clauses\n- [patternRequired](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#patternrequired-proposed) - like `required` but with patterns that some property should match.\n- [formatMaximum, formatMinimum, formatExclusiveMaximum, formatExclusiveMinimum](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#formatmaximum--formatminimum-and-exclusiveformatmaximum--exclusiveformatminimum-proposed) - setting limits for date, time, etc.\n\nSee [JSON Schema validation keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md) for more details.\n\n\n## Formats\n\nThe following formats are supported for string validation with \"format\" keyword:\n\n- _date_: full-date according to [RFC3339](http://tools.ietf.org/html/rfc3339#section-5.6).\n- _time_: time with optional time-zone.\n- _date-time_: date-time from the same source (time-zone is mandatory). `date`, `time` and `date-time` validate ranges in `full` mode and only regexp in `fast` mode (see [options](#options)).\n- _uri_: full uri with optional protocol.\n- _url_: [URL record](https://url.spec.whatwg.org/#concept-url).\n- _uri-template_: URI template according to [RFC6570](https://tools.ietf.org/html/rfc6570)\n- _email_: email address.\n- _hostname_: host name according to [RFC1034](http://tools.ietf.org/html/rfc1034#section-3.5).\n- _ipv4_: IP address v4.\n- _ipv6_: IP address v6.\n- _regex_: tests whether a string is a valid regular expression by passing it to RegExp constructor.\n- _uuid_: Universally Unique IDentifier according to [RFC4122](http://tools.ietf.org/html/rfc4122).\n- _json-pointer_: JSON-pointer according to [RFC6901](https://tools.ietf.org/html/rfc6901).\n- _relative-json-pointer_: relative JSON-pointer according to [this draft](http://tools.ietf.org/html/draft-luff-relative-json-pointer-00).\n\nThere are two modes of format validation: `fast` and `full`. This mode affects formats `date`, `time`, `date-time`, `uri`, `email`, and `hostname`. See [Options](#options) for details.\n\nYou can add additional formats and replace any of the formats above using [addFormat](#api-addformat) method.\n\nThe option `unknownFormats` allows changing the default behaviour when an unknown format is encountered. In this case Ajv can either fail schema compilation (default) or ignore it (default in versions before 5.0.0). You also can whitelist specific format(s) to be ignored. See [Options](#options) for details.\n\nYou can find patterns used for format validation and the sources that were used in [formats.js](https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js).\n\n\n## <a name=\"ref\"></a>Combining schemas with $ref\n\nYou can structure your validation logic across multiple schema files and have schemas reference each other using `$ref` keyword.\n\nExample:\n\n```javascript\nvar schema = {\n \"$id\": \"http://example.com/schemas/schema.json\",\n \"type\": \"object\",\n \"properties\": {\n \"foo\": { \"$ref\": \"defs.json#/definitions/int\" },\n \"bar\": { \"$ref\": \"defs.json#/definitions/str\" }\n }\n};\n\nvar defsSchema = {\n \"$id\": \"http://example.com/schemas/defs.json\",\n \"definitions\": {\n \"int\": { \"type\": \"integer\" },\n \"str\": { \"type\": \"string\" }\n }\n};\n```\n\nNow to compile your schema you can either pass all schemas to Ajv instance:\n\n```javascript\nvar ajv = new Ajv({schemas: [schema, defsSchema]});\nvar validate = ajv.getSchema('http://example.com/schemas/schema.json');\n```\n\nor use `addSchema` method:\n\n```javascript\nvar ajv = new Ajv;\nvar validate = ajv.addSchema(defsSchema)\n .compile(schema);\n```\n\nSee [Options](#options) and [addSchema](#api) method.\n\n__Please note__:\n- `$ref` is resolved as the uri-reference using schema $id as the base URI (see the example).\n- References can be recursive (and mutually recursive) to implement the schemas for different data structures (such as linked lists, trees, graphs, etc.).\n- You don't have to host your schema files at the URIs that you use as schema $id. These URIs are only used to identify the schemas, and according to JSON Schema specification validators should not expect to be able to download the schemas from these URIs.\n- The actual location of the schema file in the file system is not used.\n- You can pass the identifier of the schema as the second parameter of `addSchema` method or as a property name in `schemas` option. This identifier can be used instead of (or in addition to) schema $id.\n- You cannot have the same $id (or the schema identifier) used for more than one schema - the exception will be thrown.\n- You can implement dynamic resolution of the referenced schemas using `compileAsync` method. In this way you can store schemas in any system (files, web, database, etc.) and reference them without explicitly adding to Ajv instance. See [Asynchronous schema compilation](#asynchronous-schema-compilation).\n\n\n## $data reference\n\nWith `$data` option you can use values from the validated data as the values for the schema keywords. See [proposal](https://github.com/json-schema/json-schema/wiki/$data-(v5-proposal)) for more information about how it works.\n\n`$data` reference is supported in the keywords: const, enum, format, maximum/minimum, exclusiveMaximum / exclusiveMinimum, maxLength / minLength, maxItems / minItems, maxProperties / minProperties, formatMaximum / formatMinimum, formatExclusiveMaximum / formatExclusiveMinimum, multipleOf, pattern, required, uniqueItems.\n\nThe value of \"$data\" should be a [JSON-pointer](https://tools.ietf.org/html/rfc6901) to the data (the root is always the top level data object, even if the $data reference is inside a referenced subschema) or a [relative JSON-pointer](http://tools.ietf.org/html/draft-luff-relative-json-pointer-00) (it is relative to the current point in data; if the $data reference is inside a referenced subschema it cannot point to the data outside of the root level for this subschema).\n\nExamples.\n\nThis schema requires that the value in property `smaller` is less or equal than the value in the property larger:\n\n```javascript\nvar ajv = new Ajv({$data: true});\n\nvar schema = {\n \"properties\": {\n \"smaller\": {\n \"type\": \"number\",\n \"maximum\": { \"$data\": \"1/larger\" }\n },\n \"larger\": { \"type\": \"number\" }\n }\n};\n\nvar validData = {\n smaller: 5,\n larger: 7\n};\n\najv.validate(schema, validData); // true\n```\n\nThis schema requires that the properties have the same format as their field names:\n\n```javascript\nvar schema = {\n \"additionalProperties\": {\n \"type\": \"string\",\n \"format\": { \"$data\": \"0#\" }\n }\n};\n\nvar validData = {\n 'date-time': '1963-06-19T08:30:06.283185Z',\n email: 'joe.bloggs@example.com'\n}\n```\n\n`$data` reference is resolved safely - it won't throw even if some property is undefined. If `$data` resolves to `undefined` the validation succeeds (with the exclusion of `const` keyword). If `$data` resolves to incorrect type (e.g. not \"number\" for maximum keyword) the validation fails.\n\n\n## $merge and $patch keywords\n\nWith the package [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) you can use the keywords `$merge` and `$patch` that allow extending JSON-schemas with patches using formats [JSON Merge Patch (RFC 7396)](https://tools.ietf.org/html/rfc7396) and [JSON Patch (RFC 6902)](https://tools.ietf.org/html/rfc6902).\n\nTo add keywords `$merge` and `$patch` to Ajv instance use this code:\n\n```javascript\nrequire('ajv-merge-patch')(ajv);\n```\n\nExamples.\n\nUsing `$merge`:\n\n```json\n{\n \"$merge\": {\n \"source\": {\n \"type\": \"object\",\n \"properties\": { \"p\": { \"type\": \"string\" } },\n \"additionalProperties\": false\n },\n \"with\": {\n \"properties\": { \"q\": { \"type\": \"number\" } }\n }\n }\n}\n```\n\nUsing `$patch`:\n\n```json\n{\n \"$patch\": {\n \"source\": {\n \"type\": \"object\",\n \"properties\": { \"p\": { \"type\": \"string\" } },\n \"additionalProperties\": false\n },\n \"with\": [\n { \"op\": \"add\", \"path\": \"/properties/q\", \"value\": { \"type\": \"number\" } }\n ]\n }\n}\n```\n\nThe schemas above are equivalent to this schema:\n\n```json\n{\n \"type\": \"object\",\n \"properties\": {\n \"p\": { \"type\": \"string\" },\n \"q\": { \"type\": \"number\" }\n },\n \"additionalProperties\": false\n}\n```\n\nThe properties `source` and `with` in the keywords `$merge` and `$patch` can use absolute or relative `$ref` to point to other schemas previously added to the Ajv instance or to the fragments of the current schema.\n\nSee the package [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) for more information.\n\n\n## Defining custom keywords\n\nThe advantages of using custom keywords are:\n\n- allow creating validation scenarios that cannot be expressed using JSON Schema\n- simplify your schemas\n- help bringing a bigger part of the validation logic to your schemas\n- make your schemas more expressive, less verbose and closer to your application domain\n- implement custom data processors that modify your data (`modifying` option MUST be used in keyword definition) and/or create side effects while the data is being validated\n\nIf a keyword is used only for side-effects and its validation result is pre-defined, use option `valid: true/false` in keyword definition to simplify both generated code (no error handling in case of `valid: true`) and your keyword functions (no need to return any validation result).\n\nThe concerns you have to be aware of when extending JSON-schema standard with custom keywords are the portability and understanding of your schemas. You will have to support these custom keywords on other platforms and to properly document these keywords so that everybody can understand them in your schemas.\n\nYou can define custom keywords with [addKeyword](#api-addkeyword) method. Keywords are defined on the `ajv` instance level - new instances will not have previously defined keywords.\n\nAjv allows defining keywords with:\n- validation function\n- compilation function\n- macro function\n- inline compilation function that should return code (as string) that will be inlined in the currently compiled schema.\n\nExample. `range` and `exclusiveRange` keywords using compiled schema:\n\n```javascript\najv.addKeyword('range', {\n type: 'number',\n compile: function (sch, parentSchema) {\n var min = sch[0];\n var max = sch[1];\n\n return parentSchema.exclusiveRange === true\n ? function (data) { return data > min && data < max; }\n : function (data) { return data >= min && data <= max; }\n }\n});\n\nvar schema = { \"range\": [2, 4], \"exclusiveRange\": true };\nvar validate = ajv.compile(schema);\nconsole.log(validate(2.01)); // true\nconsole.log(validate(3.99)); // true\nconsole.log(validate(2)); // false\nconsole.log(validate(4)); // false\n```\n\nSeveral custom keywords (typeof, instanceof, range and propertyNames) are defined in [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package - they can be used for your schemas and as a starting point for your own custom keywords.\n\nSee [Defining custom keywords](https://github.com/epoberezkin/ajv/blob/master/CUSTOM.md) for more details.\n\n\n## Asynchronous schema compilation\n\nDuring asynchronous compilation remote references are loaded using supplied function. See `compileAsync` [method](#api-compileAsync) and `loadSchema` [option](#options).\n\nExample:\n\n```javascript\nvar ajv = new Ajv({ loadSchema: loadSchema });\n\najv.compileAsync(schema).then(function (validate) {\n var valid = validate(data);\n // ...\n});\n\nfunction loadSchema(uri) {\n return request.json(uri).then(function (res) {\n if (res.statusCode >= 400)\n throw new Error('Loading error: ' + res.statusCode);\n return res.body;\n });\n}\n```\n\n__Please note__: [Option](#options) `missingRefs` should NOT be set to `\"ignore\"` or `\"fail\"` for asynchronous compilation to work.\n\n\n## Asynchronous validation\n\nExample in Node.js REPL: https://tonicdev.com/esp/ajv-asynchronous-validation\n\nYou can define custom formats and keywords that perform validation asynchronously by accessing database or some other service. You should add `async: true` in the keyword or format definition (see [addFormat](#api-addformat), [addKeyword](#api-addkeyword) and [Defining custom keywords](#defining-custom-keywords)).\n\nIf your schema uses asynchronous formats/keywords or refers to some schema that contains them it should have `\"$async\": true` keyword so that Ajv can compile it correctly. If asynchronous format/keyword or reference to asynchronous schema is used in the schema without `$async` keyword Ajv will throw an exception during schema compilation.\n\n__Please note__: all asynchronous subschemas that are referenced from the current or other schemas should have `\"$async\": true` keyword as well, otherwise the schema compilation will fail.\n\nValidation function for an asynchronous custom format/keyword should return a promise that resolves with `true` or `false` (or rejects with `new Ajv.ValidationError(errors)` if you want to return custom errors from the keyword function). Ajv compiles asynchronous schemas to either [es7 async functions](http://tc39.github.io/ecmascript-asyncawait/) that can optionally be transpiled with [nodent](https://github.com/MatAtBread/nodent) or with [regenerator](https://github.com/facebook/regenerator) or to [generator functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) that can be optionally transpiled with regenerator as well. You can also supply any other transpiler as a function. See [Options](#options).\n\nThe compiled validation function has `$async: true` property (if the schema is asynchronous), so you can differentiate these functions if you are using both synchronous and asynchronous schemas.\n\nIf you are using generators, the compiled validation function can be either wrapped with [co](https://github.com/tj/co) (default) or returned as generator function, that can be used directly, e.g. in [koa](http://koajs.com/) 1.0. `co` is a small library, it is included in Ajv (both as npm dependency and in the browser bundle).\n\nAsync functions are currently supported in Chrome 55, Firefox 52, Node.js 7 (with --harmony-async-await) and MS Edge 13 (with flag).\n\nGenerator functions are currently supported in Chrome, Firefox and Node.js.\n\nIf you are using Ajv in other browsers or in older versions of Node.js you should use one of available transpiling options. All provided async modes use global Promise class. If your platform does not have Promise you should use a polyfill that defines it.\n\nValidation result will be a promise that resolves with validated data or rejects with an exception `Ajv.ValidationError` that contains the array of validation errors in `errors` property.\n\n\nExample:\n\n```javascript\n/**\n * Default mode is non-transpiled generator function wrapped with `co`.\n * Using package ajv-async (https://github.com/epoberezkin/ajv-async)\n * you can auto-detect the best async mode.\n * In this case, without \"async\" and \"transpile\" options\n * (or with option {async: true})\n * Ajv will choose the first supported/installed option in this order:\n * 1. native async function\n * 2. native generator function wrapped with co\n * 3. es7 async functions transpiled with nodent\n * 4. es7 async functions transpiled with regenerator\n */\n\nvar setupAsync = require('ajv-async');\nvar ajv = setupAsync(new Ajv);\n\najv.addKeyword('idExists', {\n async: true,\n type: 'number',\n validate: checkIdExists\n});\n\n\nfunction checkIdExists(schema, data) {\n return knex(schema.table)\n .select('id')\n .where('id', data)\n .then(function (rows) {\n return !!rows.length; // true if record is found\n });\n}\n\nvar schema = {\n \"$async\": true,\n \"properties\": {\n \"userId\": {\n \"type\": \"integer\",\n \"idExists\": { \"table\": \"users\" }\n },\n \"postId\": {\n \"type\": \"integer\",\n \"idExists\": { \"table\": \"posts\" }\n }\n }\n};\n\nvar validate = ajv.compile(schema);\n\nvalidate({ userId: 1, postId: 19 })\n.then(function (data) {\n console.log('Data is valid', data); // { userId: 1, postId: 19 }\n})\n.catch(function (err) {\n if (!(err instanceof Ajv.ValidationError)) throw err;\n // data is invalid\n console.log('Validation errors:', err.errors);\n});\n```\n\n### Using transpilers with asynchronous validation functions.\n\nTo use a transpiler you should separately install it (or load its bundle in the browser).\n\nAjv npm package includes minified browser bundles of regenerator and nodent in dist folder.\n\n\n#### Using nodent\n\n```javascript\nvar setupAsync = require('ajv-async');\nvar ajv = new Ajv({ /* async: 'es7', */ transpile: 'nodent' });\nsetupAsync(ajv);\nvar validate = ajv.compile(schema); // transpiled es7 async function\nvalidate(data).then(successFunc).catch(errorFunc);\n```\n\n`npm install nodent` or use `nodent.min.js` from dist folder of npm package.\n\n\n#### Using regenerator\n\n```javascript\nvar setupAsync = require('ajv-async');\nvar ajv = new Ajv({ /* async: 'es7', */ transpile: 'regenerator' });\nsetupAsync(ajv);\nvar validate = ajv.compile(schema); // transpiled es7 async function\nvalidate(data).then(successFunc).catch(errorFunc);\n```\n\n`npm install regenerator` or use `regenerator.min.js` from dist folder of npm package.\n\n\n#### Using other transpilers\n\n```javascript\nvar ajv = new Ajv({ async: 'es7', processCode: transpileFunc });\nvar validate = ajv.compile(schema); // transpiled es7 async function\nvalidate(data).then(successFunc).catch(errorFunc);\n```\n\nSee [Options](#options).\n\n\n#### Comparison of async modes\n\n|mode|transpile<br>speed*|run-time<br>speed*|bundle<br>size|\n|---|:-:|:-:|:-:|\n|es7 async<br>(native)|-|0.75|-|\n|generators<br>(native)|-|1.0|-|\n|es7.nodent|1.35|1.1|215Kb|\n|es7.regenerator|1.0|2.7|1109Kb|\n|regenerator|1.0|3.2|1109Kb|\n\n\\* Relative performance in Node.js 7.x — smaller is better.\n\n[nodent](https://github.com/MatAtBread/nodent) has several advantages:\n\n- much smaller browser bundle than regenerator\n- almost the same performance of generated code as native generators in Node.js and the latest Chrome\n- much better performance than native generators in other browsers\n- works in IE 9 (regenerator does not)\n\n\n## Filtering data\n\nWith [option `removeAdditional`](#options) (added by [andyscott](https://github.com/andyscott)) you can filter data during the validation.\n\nThis option modifies original data.\n\nExample:\n\n```javascript\nvar ajv = new Ajv({ removeAdditional: true });\nvar schema = {\n \"additionalProperties\": false,\n \"properties\": {\n \"foo\": { \"type\": \"number\" },\n \"bar\": {\n \"additionalProperties\": { \"type\": \"number\" },\n \"properties\": {\n \"baz\": { \"type\": \"string\" }\n }\n }\n }\n}\n\nvar data = {\n \"foo\": 0,\n \"additional1\": 1, // will be removed; `additionalProperties` == false\n \"bar\": {\n \"baz\": \"abc\",\n \"additional2\": 2 // will NOT be removed; `additionalProperties` != false\n },\n}\n\nvar validate = ajv.compile(schema);\n\nconsole.log(validate(data)); // true\nconsole.log(data); // { \"foo\": 0, \"bar\": { \"baz\": \"abc\", \"additional2\": 2 }\n```\n\nIf `removeAdditional` option in the example above were `\"all\"` then both `additional1` and `additional2` properties would have been removed.\n\nIf the option were `\"failing\"` then property `additional1` would have been removed regardless of its value and property `additional2` would have been removed only if its value were failing the schema in the inner `additionalProperties` (so in the example above it would have stayed because it passes the schema, but any non-number would have been removed).\n\n__Please note__: If you use `removeAdditional` option with `additionalProperties` keyword inside `anyOf`/`oneOf` keywords your validation can fail with this schema, for example:\n\n```json\n{\n \"type\": \"object\",\n \"oneOf\": [\n {\n \"properties\": {\n \"foo\": { \"type\": \"string\" }\n },\n \"required\": [ \"foo\" ],\n \"additionalProperties\": false\n },\n {\n \"properties\": {\n \"bar\": { \"type\": \"integer\" }\n },\n \"required\": [ \"bar\" ],\n \"additionalProperties\": false\n }\n ]\n}\n```\n\nThe intention of the schema above is to allow objects with either the string property \"foo\" or the integer property \"bar\", but not with both and not with any other properties.\n\nWith the option `removeAdditional: true` the validation will pass for the object `{ \"foo\": \"abc\"}` but will fail for the object `{\"bar\": 1}`. It happens because while the first subschema in `oneOf` is validated, the property `bar` is removed because it is an additional property according to the standard (because it is not included in `properties` keyword in the same schema).\n\nWhile this behaviour is unexpected (issues [#129](https://github.com/epoberezkin/ajv/issues/129), [#134](https://github.com/epoberezkin/ajv/issues/134)), it is correct. To have the expected behaviour (both objects are allowed and additional properties are removed) the schema has to be refactored in this way:\n\n```json\n{\n \"type\": \"object\",\n \"properties\": {\n \"foo\": { \"type\": \"string\" },\n \"bar\": { \"type\": \"integer\" }\n },\n \"additionalProperties\": false,\n \"oneOf\": [\n { \"required\": [ \"foo\" ] },\n { \"required\": [ \"bar\" ] }\n ]\n}\n```\n\nThe schema above is also more efficient - it will compile into a faster function.\n\n\n## Assigning defaults\n\nWith [option `useDefaults`](#options) Ajv will assign values from `default` keyword in the schemas of `properties` and `items` (when it is the array of schemas) to the missing properties and items.\n\nThis option modifies original data.\n\n__Please note__: by default the default value is inserted in the generated validation code as a literal (starting from v4.0), so the value inserted in the data will be the deep clone of the default in the schema.\n\nIf you need to insert the default value in the data by reference pass the option `useDefaults: \"shared\"`.\n\nInserting defaults by reference can be faster (in case you have an object in `default`) and it allows to have dynamic values in defaults, e.g. timestamp, without recompiling the schema. The side effect is that modifying the default value in any validated data instance will change the default in the schema and in other validated data instances. See example 3 below.\n\n\nExample 1 (`default` in `properties`):\n\n```javascript\nvar ajv = new Ajv({ useDefaults: true });\nvar schema = {\n \"type\": \"object\",\n \"properties\": {\n \"foo\": { \"type\": \"number\" },\n \"bar\": { \"type\": \"string\", \"default\": \"baz\" }\n },\n \"required\": [ \"foo\", \"bar\" ]\n};\n\nvar data = { \"foo\": 1 };\n\nvar validate = ajv.compile(schema);\n\nconsole.log(validate(data)); // true\nconsole.log(data); // { \"foo\": 1, \"bar\": \"baz\" }\n```\n\nExample 2 (`default` in `items`):\n\n```javascript\nvar schema = {\n \"type\": \"array\",\n \"items\": [\n { \"type\": \"number\" },\n { \"type\": \"string\", \"default\": \"foo\" }\n ]\n}\n\nvar data = [ 1 ];\n\nvar validate = ajv.compile(schema);\n\nconsole.log(validate(data)); // true\nconsole.log(data); // [ 1, \"foo\" ]\n```\n\nExample 3 (inserting \"defaults\" by reference):\n\n```javascript\nvar ajv = new Ajv({ useDefaults: 'shared' });\n\nvar schema = {\n properties: {\n foo: {\n default: { bar: 1 }\n }\n }\n}\n\nvar validate = ajv.compile(schema);\n\nvar data = {};\nconsole.log(validate(data)); // true\nconsole.log(data); // { foo: { bar: 1 } }\n\ndata.foo.bar = 2;\n\nvar data2 = {};\nconsole.log(validate(data2)); // true\nconsole.log(data2); // { foo: { bar: 2 } }\n```\n\n`default` keywords in other cases are ignored:\n\n- not in `properties` or `items` subschemas\n- in schemas inside `anyOf`, `oneOf` and `not` (see [#42](https://github.com/epoberezkin/ajv/issues/42))\n- in `if` subschema of `switch` keyword\n- in schemas generated by custom macro keywords\n\n\n## Coercing data types\n\nWhen you are validating user inputs all your data properties are usually strings. The option `coerceTypes` allows you to have your data types coerced to the types specified in your schema `type` keywords, both to pass the validation and to use the correctly typed data afterwards.\n\nThis option modifies original data.\n\n__Please note__: if you pass a scalar value to the validating function its type will be coerced and it will pass the validation, but the value of the variable you pass won't be updated because scalars are passed by value.\n\n\nExample 1:\n\n```javascript\nvar ajv = new Ajv({ coerceTypes: true });\nvar schema = {\n \"type\": \"object\",\n \"properties\": {\n \"foo\": { \"type\": \"number\" },\n \"bar\": { \"type\": \"boolean\" }\n },\n \"required\": [ \"foo\", \"bar\" ]\n};\n\nvar data = { \"foo\": \"1\", \"bar\": \"false\" };\n\nvar validate = ajv.compile(schema);\n\nconsole.log(validate(data)); // true\nconsole.log(data); // { \"foo\": 1, \"bar\": false }\n```\n\nExample 2 (array coercions):\n\n```javascript\nvar ajv = new Ajv({ coerceTypes: 'array' });\nvar schema = {\n \"properties\": {\n \"foo\": { \"type\": \"array\", \"items\": { \"type\": \"number\" } },\n \"bar\": { \"type\": \"boolean\" }\n }\n};\n\nvar data = { \"foo\": \"1\", \"bar\": [\"false\"] };\n\nvar validate = ajv.compile(schema);\n\nconsole.log(validate(data)); // true\nconsole.log(data); // { \"foo\": [1], \"bar\": false }\n```\n\nThe coercion rules, as you can see from the example, are different from JavaScript both to validate user input as expected and to have the coercion reversible (to correctly validate cases where different types are defined in subschemas of \"anyOf\" and other compound keywords).\n\nSee [Coercion rules](https://github.com/epoberezkin/ajv/blob/master/COERCION.md) for details.\n\n\n## API\n\n##### new Ajv(Object options) -> Object\n\nCreate Ajv instance.\n\n\n##### .compile(Object schema) -> Function<Object data>\n\nGenerate validating function and cache the compiled schema for future use.\n\nValidating function returns boolean and has properties `errors` with the errors from the last validation (`null` if there were no errors) and `schema` with the reference to the original schema.\n\nUnless the option `validateSchema` is false, the schema will be validated against meta-schema and if schema is invalid the error will be thrown. See [options](#options).\n\n\n##### <a name=\"api-compileAsync\"></a>.compileAsync(Object schema [, Boolean meta] [, Function callback]) -> Promise\n\nAsynchronous version of `compile` method that loads missing remote schemas using asynchronous function in `options.loadSchema`. This function returns a Promise that resolves to a validation function. An optional callback passed to `compileAsync` will be called with 2 parameters: error (or null) and validating function. The returned promise will reject (and the callback will be called with an error) when:\n\n- missing schema can't be loaded (`loadSchema` returns a Promise that rejects).\n- a schema containing a missing reference is loaded, but the reference cannot be resolved.\n- schema (or some loaded/referenced schema) is invalid.\n\nThe function compiles schema and loads the first missing schema (or meta-schema) until all missing schemas are loaded.\n\nYou can asynchronously compile meta-schema by passing `true` as the second parameter.\n\nSee example in [Asynchronous compilation](#asynchronous-schema-compilation).\n\n\n##### .validate(Object schema|String key|String ref, data) -> Boolean\n\nValidate data using passed schema (it will be compiled and cached).\n\nInstead of the schema you can use the key that was previously passed to `addSchema`, the schema id if it was present in the schema or any previously resolved reference.\n\nValidation errors will be available in the `errors` property of Ajv instance (`null` if there were no errors).\n\n__Please note__: every time this method is called the errors are overwritten so you need to copy them to another variable if you want to use them later.\n\nIf the schema is asynchronous (has `$async` keyword on the top level) this method returns a Promise. See [Asynchronous validation](#asynchronous-validation).\n\n\n##### .addSchema(Array<Object>|Object schema [, String key]) -> Ajv\n\nAdd schema(s) to validator instance. This method does not compile schemas (but it still validates them). Because of that dependencies can be added in any order and circular dependencies are supported. It also prevents unnecessary compilation of schemas that are containers for other schemas but not used as a whole.\n\nArray of schemas can be passed (schemas should have ids), the second parameter will be ignored.\n\nKey can be passed that can be used to reference the schema and will be used as the schema id if there is no id inside the schema. If the key is not passed, the schema id will be used as the key.\n\n\nOnce the schema is added, it (and all the references inside it) can be referenced in other schemas and used to validate data.\n\nAlthough `addSchema` does not compile schemas, explicit compilation is not required - the schema will be compiled when it is used first time.\n\nBy default the schema is validated against meta-schema before it is added, and if the schema does not pass validation the exception is thrown. This behaviour is controlled by `validateSchema` option.\n\n__Please note__: Ajv uses the [method chaining syntax](https://en.wikipedia.org/wiki/Method_chaining) for all methods with the prefix `add*` and `remove*`.\nThis allows you to do nice things like the following.\n\n```javascript\nvar validate = new Ajv().addSchema(schema).addFormat(name, regex).getSchema(uri);\n``` \n\n##### .addMetaSchema(Array<Object>|Object schema [, String key]) -> Ajv\n\nAdds meta schema(s) that can be used to validate other schemas. That function should be used instead of `addSchema` because there may be instance options that would compile a meta schema incorrectly (at the moment it is `removeAdditional` option).\n\nThere is no need to explicitly add draft 6 meta schema (http://json-schema.org/draft-06/schema and http://json-schema.org/schema) - it is added by default, unless option `meta` is set to `false`. You only need to use it if you have a changed meta-schema that you want to use to validate your schemas. See `validateSchema`.\n\n\n##### <a name=\"api-validateschema\"></a>.validateSchema(Object schema) -> Boolean\n\nValidates schema. This method should be used to validate schemas rather than `validate` due to the inconsistency of `uri` format in JSON Schema standard.\n\nBy default this method is called automatically when the schema is added, so you rarely need to use it directly.\n\nIf schema doesn't have `$schema` property, it is validated against draft 6 meta-schema (option `meta` should not be false).\n\nIf schema has `$schema` property, then the schema with this id (that should be previously added) is used to validate passed schema.\n\nErrors will be available at `ajv.errors`.\n\n\n##### .getSchema(String key) -> Function<Object data>\n\nRetrieve compiled schema previously added with `addSchema` by the key passed to `addSchema` or by its full reference (id). The returned validating function has `schema` property with the reference to the original schema.\n\n\n##### .removeSchema([Object schema|String key|String ref|RegExp pattern]) -> Ajv\n\nRemove added/cached schema. Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references.\n\nSchema can be removed using:\n- key passed to `addSchema`\n- it's full reference (id)\n- RegExp that should match schema id or key (meta-schemas won't be removed)\n- actual schema object that will be stable-stringified to remove schema from cache\n\nIf no parameter is passed all schemas but meta-schemas will be removed and the cache will be cleared.\n\n\n##### <a name=\"api-addformat\"></a>.addFormat(String name, String|RegExp|Function|Object format) -> Ajv\n\nAdd custom format to validate strings or numbers. It can also be used to replace pre-defined formats for Ajv instance.\n\nStrings are converted to RegExp.\n\nFunction should return validation result as `true` or `false`.\n\nIf object is passed it should have properties `validate`, `compare` and `async`:\n\n- _validate_: a string, RegExp or a function as described above.\n- _compare_: an optional comparison function that accepts two strings and compares them according to the format meaning. This function is used with keywords `formatMaximum`/`formatMinimum` (defined in [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package). It should return `1` if the first value is bigger than the second value, `-1` if it is smaller and `0` if it is equal.\n- _async_: an optional `true` value if `validate` is an asynchronous function; in this case it should return a promise that resolves with a value `true` or `false`.\n- _type_: an optional type of data that the format applies to. It can be `\"string\"` (default) or `\"number\"` (see https://github.com/epoberezkin/ajv/issues/291#issuecomment-259923858). If the type of data is different, the validation will pass.\n\nCustom formats can be also added via `formats` option.\n\n\n##### <a name=\"api-addkeyword\"></a>.addKeyword(String keyword, Object definition) -> Ajv\n\nAdd custom validation keyword to Ajv instance.\n\nKeyword should be different from all standard JSON schema keywords and different from previously defined keywords. There is no way to redefine keywords or to remove keyword definition from the instance.\n\nKeyword must start with a letter, `_` or `$`, and may continue with letters, numbers, `_`, `$`, or `-`.\nIt is recommended to use an application-specific prefix for keywords to avoid current and future name collisions.\n\nExample Keywords:\n- `\"xyz-example\"`: valid, and uses prefix for the xyz project to avoid name collisions.\n- `\"example\"`: valid, but not recommended as it could collide with future versions of JSON schema etc.\n- `\"3-example\"`: invalid as numbers are not allowed to be the first character in a keyword\n\nKeyword definition is an object with the following properties:\n\n- _type_: optional string or array of strings with data type(s) that the keyword applies to. If not present, the keyword will apply to all types.\n- _validate_: validating function\n- _compile_: compiling function\n- _macro_: macro function\n- _inline_: compiling function that returns code (as string)\n- _schema_: an optional `false` value used with \"validate\" keyword to not pass schema\n- _metaSchema_: an optional meta-schema for keyword schema\n- _modifying_: `true` MUST be passed if keyword modifies data\n- _valid_: pass `true`/`false` to pre-define validation result, the result returned from validation function will be ignored. This option cannot be used with macro keywords.\n- _$data_: an optional `true` value to support [$data reference](#data-reference) as the value of custom keyword. The reference will be resolved at validation time. If the keyword has meta-schema it would be extended to allow $data and it will be used to validate the resolved value. Supporting $data reference requires that keyword has validating function (as the only option or in addition to compile, macro or inline function).\n- _async_: an optional `true` value if the validation function is asynchronous (whether it is compiled or passed in _validate_ property); in this case it should return a promise that resolves with a value `true` or `false`. This option is ignored in case of \"macro\" and \"inline\" keywords.\n- _errors_: an optional boolean indicating whether keyword returns errors. If this property is not set Ajv will determine if the errors were set in case of failed validation.\n\n_compile_, _macro_ and _inline_ are mutually exclusive, only one should be used at a time. _validate_ can be used separately or in addition to them to support $data reference.\n\n__Please note__: If the keyword is validating data type that is different from the type(s) in its definition, the validation function will not be called (and expanded macro will not be used), so there is no need to check for data type inside validation function or inside schema returned by macro function (unless you want to enforce a specific type and for some reason do not want to use a separate `type` keyword for that). In the same way as standard keywords work, if the keyword does not apply to the data type being validated, the validation of this keyword will succeed.\n\nSee [Defining custom keywords](#defining-custom-keywords) for more details.\n\n\n##### .getKeyword(String keyword) -> Object|Boolean\n\nReturns custom keyword definition, `true` for pre-defined keywords and `false` if the keyword is unknown.\n\n\n##### .removeKeyword(String keyword) -> Ajv\n\nRemoves custom or pre-defined keyword so you can redefine them.\n\nWhile this method can be used to extend pre-defined keywords, it can also be used to completely change their meaning - it may lead to unexpected results.\n\n__Please note__: schemas compiled before the keyword is removed will continue to work without changes. To recompile schemas use `removeSchema` method and compile them again.\n\n\n##### .errorsText([Array<Object> errors [, Object options]]) -> String\n\nReturns the text with all errors in a String.\n\nOptions can have properties `separator` (string used to separate errors, \", \" by default) and `dataVar` (the variable name that dataPaths are prefixed with, \"data\" by default).\n\n\n## Options\n\nDefaults:\n\n```javascript\n{\n // validation and reporting options:\n $data: false,\n allErrors: false,\n verbose: false,\n jsonPointers: false,\n uniqueItems: true,\n unicode: true,\n format: 'fast',\n formats: {},\n unknownFormats: true,\n schemas: {},\n logger: undefined,\n // referenced schema options:\n schemaId: undefined // recommended '$id'\n missingRefs: true,\n extendRefs: 'ignore', // recommended 'fail'\n loadSchema: undefined, // function(uri: string): Promise {}\n // options to modify validated data:\n removeAdditional: false,\n useDefaults: false,\n coerceTypes: false,\n // asynchronous validation options:\n async: 'co*',\n transpile: undefined, // requires ajv-async package\n // advanced options:\n meta: true,\n validateSchema: true,\n addUsedSchema: true,\n inlineRefs: true,\n passContext: false,\n loopRequired: Infinity,\n ownProperties: false,\n multipleOfPrecision: false,\n errorDataPath: 'object',\n messages: true,\n sourceCode: false,\n processCode: undefined, // function (str: string): string {}\n cache: new Cache,\n serialize: undefined\n}\n```\n\n##### Validation and reporting options\n\n- _$data_: support [$data references](#data-reference). Draft 6 meta-schema that is added by default will be extended to allow them. If you want to use another meta-schema you need to use $dataMetaSchema method to add support for $data reference. See [API](#api).\n- _allErrors_: check all rules collecting all errors. Default is to return after the first error.\n- _verbose_: include the reference to the part of the schema (`schema` and `parentSchema`) and validated data in errors (false by default).\n- _jsonPointers_: set `dataPath` property of errors using [JSON Pointers](https://tools.ietf.org/html/rfc6901) instead of JavaScript property access notation.\n- _uniqueItems_: validate `uniqueItems` keyword (true by default).\n- _unicode_: calculate correct length of strings with unicode pairs (true by default). Pass `false` to use `.length` of strings that is faster, but gives \"incorrect\" lengths of strings with unicode pairs - each unicode pair is counted as two characters.\n- _format_: formats validation mode ('fast' by default). Pass 'full' for more correct and slow validation or `false` not to validate formats at all. E.g., 25:00:00 and 2015/14/33 will be invalid time and date in 'full' mode but it will be valid in 'fast' mode.\n- _formats_: an object with custom formats. Keys and values will be passed to `addFormat` method.\n- _unknownFormats_: handling of unknown formats. Option values:\n - `true` (default) - if an unknown format is encountered the exception is thrown during schema compilation. If `format` keyword value is [$data reference](#data-reference) and it is unknown the validation will fail.\n - `[String]` - an array of unknown format names that will be ignored. This option can be used to allow usage of third party schemas with format(s) for which you don't have definitions, but still fail if another unknown format is used. If `format` keyword value is [$data reference](#data-reference) and it is not in this array the validation will fail.\n - `\"ignore\"` - to log warning during schema compilation and always pass validation (the default behaviour in versions before 5.0.0). This option is not recommended, as it allows to mistype format name and it won't be validated without any error message. This behaviour is required by JSON-schema specification.\n- _schemas_: an array or object of schemas that will be added to the instance. In case you pass the array the schemas must have IDs in them. When the object is passed the method `addSchema(value, key)` will be called for each schema in this object.\n- _logger_: sets the logging method. Default is the global `console` object that should have methods `log`, `warn` and `error`. Option values:\n - custom logger - it should have methods `log`, `warn` and `error`. If any of these methods is missing an exception will be thrown.\n - `false` - logging is disabled.\n\n\n##### Referenced schema options\n\n- _schemaId_: this option defines which keywords are used as schema URI. Option value:\n - `\"$id\"` (recommended) - only use `$id` keyword as schema URI (as specified in JSON Schema draft-06), ignore `id` keyword (if it is present a warning will be logged).\n - `\"id\"` - only use `id` keyword as schema URI (as specified in JSON Schema draft-04), ignore `$id` keyword (if it is present a warning will be logged).\n - `undefined` (default) - use both `$id` and `id` keywords as schema URI. If both are present (in the same schema object) and different the exception will be thrown during schema compilation.\n- _missingRefs_: handling of missing referenced schemas. Option values:\n - `true` (default) - if the reference cannot be resolved during compilation the exception is thrown. The thrown error has properties `missingRef` (with hash fragment) and `missingSchema` (without it). Both properties are resolved relative to the current base id (usually schema id, unless it was substituted).\n - `\"ignore\"` - to log error during compilation and always pass validation.\n - `\"fail\"` - to log error and successfully compile schema but fail validation if this rule is checked.\n- _extendRefs_: validation of other keywords when `$ref` is present in the schema. Option values:\n - `\"ignore\"` (default) - when `$ref` is used other keywords are ignored (as per [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3) standard). A warning will be logged during the schema compilation.\n - `\"fail\"` (recommended) - if other validation keywords are used together with `$ref` the exception will be thrown when the schema is compiled. This option is recommended to make sure schema has no keywords that are ignored, which can be confusing.\n - `true` - validate all keywords in the schemas with `$ref` (the default behaviour in versions before 5.0.0).\n- _loadSchema_: asynchronous function that will be used to load remote schemas when `compileAsync` [method](#api-compileAsync) is used and some reference is missing (option `missingRefs` should NOT be 'fail' or 'ignore'). This function should accept remote schema uri as a parameter and return a Promise that resolves to a schema. See example in [Asynchronous compilation](#asynchronous-schema-compilation).\n\n\n##### Options to modify validated data\n\n- _removeAdditional_: remove additional properties - see example in [Filtering data](#filtering-data). This option is not used if schema is added with `addMetaSchema` method. Option values:\n - `false` (default) - not to remove additional properties\n - `\"all\"` - all additional properties are removed, regardless of `additionalProperties` keyword in schema (and no validation is made for them).\n - `true` - only additional properties with `additionalProperties` keyword equal to `false` are removed.\n - `\"failing\"` - additional properties that fail schema validation will be removed (where `additionalProperties` keyword is `false` or schema).\n- _useDefaults_: replace missing properties and items with the values from corresponding `default` keywords. Default behaviour is to ignore `default` keywords. This option is not used if schema is added with `addMetaSchema` method. See examples in [Assigning defaults](#assigning-defaults). Option values:\n - `false` (default) - do not use defaults\n - `true` - insert defaults by value (safer and slower, object literal is used).\n - `\"shared\"` - insert defaults by reference (faster). If the default is an object, it will be shared by all instances of validated data. If you modify the inserted default in the validated data, it will be modified in the schema as well.\n- _coerceTypes_: change data type of data to match `type` keyword. See the example in [Coercing data types](#coercing-data-types) and [coercion rules](https://github.com/epoberezkin/ajv/blob/master/COERCION.md). Option values:\n - `false` (default) - no type coercion.\n - `true` - coerce scalar data types.\n - `\"array\"` - in addition to coercions between scalar types, coerce scalar data to an array with one element and vice versa (as required by the schema).\n\n\n##### Asynchronous validation options\n\n- _async_: determines how Ajv compiles asynchronous schemas (see [Asynchronous validation](#asynchronous-validation)) to functions. Option values:\n - `\"*\"` / `\"co*\"` (default) - compile to generator function (\"co*\" - wrapped with `co.wrap`). If generators are not supported and you don't provide `processCode` option (or `transpile` option if you use [ajv-async](https://github.com/epoberezkin/ajv-async) package), the exception will be thrown when async schema is compiled.\n - `\"es7\"` - compile to es7 async function. Unless your platform supports them you need to provide `processCode` or `transpile` option. According to [compatibility table](http://kangax.github.io/compat-table/es7/)) async functions are supported by:\n - Firefox 52,\n - Chrome 55,\n - Node.js 7 (with `--harmony-async-await`),\n - MS Edge 13 (with flag).\n - `undefined`/`true` - auto-detect async mode. It requires [ajv-async](https://github.com/epoberezkin/ajv-async) package. If `transpile` option is not passed, ajv-async will choose the first of supported/installed async/transpile modes in this order:\n - \"es7\" (native async functions),\n - \"co*\" (native generators with co.wrap),\n - \"es7\"/\"nodent\",\n - \"co*\"/\"regenerator\" during the creation of the Ajv instance.\n\n If none of the options is available the exception will be thrown.\n- _transpile_: Requires [ajv-async](https://github.com/epoberezkin/ajv-async) package. It determines whether Ajv transpiles compiled asynchronous validation function. Option values:\n - `\"nodent\"` - transpile with [nodent](https://github.com/MatAtBread/nodent). If nodent is not installed, the exception will be thrown. nodent can only transpile es7 async functions; it will enforce this mode.\n - `\"regenerator\"` - transpile with [regenerator](https://github.com/facebook/regenerator). If regenerator is not installed, the exception will be thrown.\n - a function - this function should accept the code of validation function as a string and return transpiled code. This option allows you to use any other transpiler you prefer. If you are passing a function, you can simply pass it to `processCode` option without using ajv-async.\n\n\n##### Advanced options\n\n- _meta_: add [meta-schema](http://json-schema.org/documentation.html) so it can be used by other schemas (true by default). If an object is passed, it will be used as the default meta-schema for schemas that have no `$schema` keyword. This default meta-schema MUST have `$schema` keyword.\n- _validateSchema_: validate added/compiled schemas against meta-schema (true by default). `$schema` property in the schema can either be http://json-schema.org/schema or http://json-schema.org/draft-04/schema or absent (draft-4 meta-schema will be used) or can be a reference to the schema previously added with `addMetaSchema` method. Option values:\n - `true` (default) - if the validation fails, throw the exception.\n - `\"log\"` - if the validation fails, log error.\n - `false` - skip schema validation.\n- _addUsedSchema_: by default methods `compile` and `validate` add schemas to the instance if they have `$id` (or `id`) property that doesn't start with \"#\". If `$id` is present and it is not unique the exception will be thrown. Set this option to `false` to skip adding schemas to the instance and the `$id` uniqueness check when these methods are used. This option does not affect `addSchema` method.\n- _inlineRefs_: Affects compilation of referenced schemas. Option values:\n - `true` (default) - the referenced schemas that don't have refs in them are inlined, regardless of their size - that substantially improves performance at the cost of the bigger size of compiled schema functions.\n - `false` - to not inline referenced schemas (they will be compiled as separate functions).\n - integer number - to limit the maximum number of keywords of the schema that will be inlined.\n- _passContext_: pass validation context to custom keyword functions. If this option is `true` and you pass some context to the compiled validation function with `validate.call(context, data)`, the `context` will be available as `this` in your custom keywords. By default `this` is Ajv instance.\n- _loopRequired_: by default `required` keyword is compiled into a single expression (or a sequence of statements in `allErrors` mode). In case of a very large number of properties in this keyword it may result in a very big validation function. Pass integer to set the number of properties above which `required` keyword will be validated in a loop - smaller validation function size but also worse performance.\n- _ownProperties_: by default Ajv iterates over all enumerable object properties; when this option is `true` only own enumerable object properties (i.e. found directly on the object rather than on its prototype) are iterated. Contributed by @mbroadst.\n- _multipleOfPrecision_: by default `multipleOf` keyword is validated by comparing the result of division with parseInt() of that result. It works for dividers that are bigger than 1. For small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer, see issue [#84](https://github.com/epoberezkin/ajv/issues/84)). If you need to use fractional dividers set this option to some positive integer N to have `multipleOf` validated using this formula: `Math.abs(Math.round(division) - division) < 1e-N` (it is slower but allows for float arithmetics deviations).\n- _errorDataPath_: set `dataPath` to point to 'object' (default) or to 'property' when validating keywords `required`, `additionalProperties` and `dependencies`.\n- _messages_: Include human-readable messages in errors. `true` by default. `false` can be passed when custom messages are used (e.g. with [ajv-i18n](https://github.com/epoberezkin/ajv-i18n)).\n- _sourceCode_: add `sourceCode` property to validating function (for debugging; this code can be different from the result of toString call).\n- _processCode_: an optional function to process generated code before it is passed to Function constructor. It can be used to either beautify (the validating function is generated without line-breaks) or to transpile code. Starting from version 5.0.0 this option replaced options:\n - `beautify` that formatted the generated function using [js-beautify](https://github.com/beautify-web/js-beautify). If you want to beautify the generated code pass `require('js-beautify').js_beautify`.\n - `transpile` that transpiled asynchronous validation function. You can still use `transpile` option with [ajv-async](https://github.com/epoberezkin/ajv-async) package. See [Asynchronous validation](#asynchronous-validation) for more information.\n- _cache_: an optional instance of cache to store compiled schemas using stable-stringified schema as a key. For example, set-associative cache [sacjs](https://github.com/epoberezkin/sacjs) can be used. If not passed then a simple hash is used which is good enough for the common use case (a limited number of statically defined schemas). Cache should have methods `put(key, value)`, `get(key)`, `del(key)` and `clear()`.\n- _serialize_: an optional function to serialize schema to cache key. Pass `false` to use schema itself as a key (e.g., if WeakMap used as a cache). By default [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used.\n\n\n## Validation errors\n\nIn case of validation failure, Ajv assigns the array of errors to `errors` property of validation function (or to `errors` property of Ajv instance when `validate` or `validateSchema` methods were called). In case of [asynchronous validation](#asynchronous-validation), the returned promise is rejected with exception `Ajv.ValidationError` that has `errors` property.\n\n\n### Error objects\n\nEach error is an object with the following properties:\n\n- _keyword_: validation keyword.\n- _dataPath_: the path to the part of the data that was validated. By default `dataPath` uses JavaScript property access notation (e.g., `\".prop[1].subProp\"`). When the option `jsonPointers` is true (see [Options](#options)) `dataPath` will be set using JSON pointer standard (e.g., `\"/prop/1/subProp\"`).\n- _schemaPath_: the path (JSON-pointer as a URI fragment) to the schema of the keyword that failed validation.\n- _params_: the object with the additional information about error that can be used to create custom error messages (e.g., using [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) package). See below for parameters set by all keywords.\n- _message_: the standard error message (can be excluded with option `messages` set to false).\n- _schema_: the schema of the keyword (added with `verbose` option).\n- _parentSchema_: the schema containing the keyword (added with `verbose` option)\n- _data_: the data validated by the keyword (added with `verbose` option).\n\n__Please note__: `propertyNames` keyword schema validation errors have an additional property `propertyName`, `dataPath` points to the object. After schema validation for each property name, if it is invalid an additional error is added with the property `keyword` equal to `\"propertyNames\"`.\n\n\n### Error parameters\n\nProperties of `params` object in errors depend on the keyword that failed validation.\n\n- `maxItems`, `minItems`, `maxLength`, `minLength`, `maxProperties`, `minProperties` - property `limit` (number, the schema of the keyword).\n- `additionalItems` - property `limit` (the maximum number of allowed items in case when `items` keyword is an array of schemas and `additionalItems` is false).\n- `additionalProperties` - property `additionalProperty` (the property not used in `properties` and `patternProperties` keywords).\n- `dependencies` - properties:\n - `property` (dependent property),\n - `missingProperty` (required missing dependency - only the first one is reported currently)\n - `deps` (required dependencies, comma separated list as a string),\n - `depsCount` (the number of required dependencies).\n- `format` - property `format` (the schema of the keyword).\n- `maximum`, `minimum` - properties:\n - `limit` (number, the schema of the keyword),\n - `exclusive` (boolean, the schema of `exclusiveMaximum` or `exclusiveMinimum`),\n - `comparison` (string, comparison operation to compare the data to the limit, with the data on the left and the limit on the right; can be \"<\", \"<=\", \">\", \">=\")\n- `multipleOf` - property `multipleOf` (the schema of the keyword)\n- `pattern` - property `pattern` (the schema of the keyword)\n- `required` - property `missingProperty` (required property that is missing).\n- `propertyNames` - property `propertyName` (an invalid property name).\n- `patternRequired` (in ajv-keywords) - property `missingPattern` (required pattern that did not match any property).\n- `type` - property `type` (required type(s), a string, can be a comma-separated list)\n- `uniqueItems` - properties `i` and `j` (indices of duplicate items).\n- `enum` - property `allowedValues` pointing to the array of values (the schema of the keyword).\n- `$ref` - property `ref` with the referenced schema URI.\n- custom keywords (in case keyword definition doesn't create errors) - property `keyword` (the keyword name).\n\n\n## Related packages\n\n- [ajv-async](https://github.com/epoberezkin/ajv-async) - configure async validation mode\n- [ajv-cli](https://github.com/jessedc/ajv-cli) - command line interface\n- [ajv-errors](https://github.com/epoberezkin/ajv-errors) - custom error messages\n- [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) - internationalised error messages\n- [ajv-istanbul](https://github.com/epoberezkin/ajv-istanbul) - instrument generated validation code to measure test coverage of your schemas\n- [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) - custom validation keywords (if/then/else, select, typeof, etc.)\n- [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) - keywords $merge and $patch\n- [ajv-pack](https://github.com/epoberezkin/ajv-pack) - produces a compact module exporting validation functions\n\n\n## Some packages using Ajv\n\n- [webpack](https://github.com/webpack/webpack) - a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser\n- [jsonscript-js](https://github.com/JSONScript/jsonscript-js) - the interpreter for [JSONScript](http://www.jsonscript.org) - scripted processing of existing endpoints and services\n- [osprey-method-handler](https://github.com/mulesoft-labs/osprey-method-handler) - Express middleware for validating requests and responses based on a RAML method object, used in [osprey](https://github.com/mulesoft/osprey) - validating API proxy generated from a RAML definition\n- [har-validator](https://github.com/ahmadnassri/har-validator) - HTTP Archive (HAR) validator\n- [jsoneditor](https://github.com/josdejong/jsoneditor) - a web-based tool to view, edit, format, and validate JSON http://jsoneditoronline.org\n- [JSON Schema Lint](https://github.com/nickcmaynard/jsonschemalint) - a web tool to validate JSON/YAML document against a single JSON-schema http://jsonschemalint.com\n- [objection](https://github.com/vincit/objection.js) - SQL-friendly ORM for Node.js\n- [table](https://github.com/gajus/table) - formats data into a string table\n- [ripple-lib](https://github.com/ripple/ripple-lib) - a JavaScript API for interacting with [Ripple](https://ripple.com) in Node.js and the browser\n- [restbase](https://github.com/wikimedia/restbase) - distributed storage with REST API & dispatcher for backend services built to provide a low-latency & high-throughput API for Wikipedia / Wikimedia content\n- [hippie-swagger](https://github.com/CacheControl/hippie-swagger) - [Hippie](https://github.com/vesln/hippie) wrapper that provides end to end API testing with swagger validation\n- [react-form-controlled](https://github.com/seeden/react-form-controlled) - React controlled form components with validation\n- [rabbitmq-schema](https://github.com/tjmehta/rabbitmq-schema) - a schema definition module for RabbitMQ graphs and messages\n- [@query/schema](https://www.npmjs.com/package/@query/schema) - stream filtering with a URI-safe query syntax parsing to JSON Schema\n- [chai-ajv-json-schema](https://github.com/peon374/chai-ajv-json-schema) - chai plugin to us JSON-schema with expect in mocha tests\n- [grunt-jsonschema-ajv](https://github.com/SignpostMarv/grunt-jsonschema-ajv) - Grunt plugin for validating files against JSON Schema\n- [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) - extract text from bundle into a file\n- [electron-builder](https://github.com/electron-userland/electron-builder) - a solution to package and build a ready for distribution Electron app\n- [addons-linter](https://github.com/mozilla/addons-linter) - Mozilla Add-ons Linter\n- [gh-pages-generator](https://github.com/epoberezkin/gh-pages-generator) - multi-page site generator converting markdown files to GitHub pages\n\n\n## Tests\n\n```\nnpm install\ngit submodule update --init\nnpm test\n```\n\n## Contributing\n\nAll validation functions are generated using doT templates in [dot](https://github.com/epoberezkin/ajv/tree/master/lib/dot) folder. Templates are precompiled so doT is not a run-time dependency.\n\n`npm run build` - compiles templates to [dotjs](https://github.com/epoberezkin/ajv/tree/master/lib/dotjs) folder.\n\n`npm run watch` - automatically compiles templates when files in dot folder change\n\nPlease see [Contributing guidelines](https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md)\n\n\n## Changes history\n\nSee https://github.com/epoberezkin/ajv/releases\n\n__Please note__: [Changes in version 5.0.0](https://github.com/epoberezkin/ajv/releases/tag/5.0.0).\n\n[Changes in version 4.6.0](https://github.com/epoberezkin/ajv/releases/tag/4.6.0).\n\n[Changes in version 4.0.0](https://github.com/epoberezkin/ajv/releases/tag/4.0.0).\n\n[Changes in version 3.0.0](https://github.com/epoberezkin/ajv/releases/tag/3.0.0).\n\n[Changes in version 2.0.0](https://github.com/epoberezkin/ajv/releases/tag/2.0.0).\n\n\n## License\n\n[MIT](https://github.com/epoberezkin/ajv/blob/master/LICENSE)\n",
|
||
"readmeFilename": "README.md",
|
||
"repository": {
|
||
"type": "git",
|
||
"url": "git+https://github.com/epoberezkin/ajv.git"
|
||
},
|
||
"scripts": {
|
||
"build": "del-cli lib/dotjs/*.js && node scripts/compile-dots.js",
|
||
"bundle": "node ./scripts/bundle.js . Ajv pure_getters",
|
||
"bundle-all": "del-cli dist && npm run bundle && npm run bundle-regenerator && npm run bundle-nodent",
|
||
"bundle-beautify": "node ./scripts/bundle.js js-beautify",
|
||
"bundle-nodent": "node ./scripts/bundle.js nodent",
|
||
"bundle-regenerator": "node ./scripts/bundle.js regenerator",
|
||
"eslint": "if-node-version \">=4\" eslint lib/*.js lib/compile/*.js spec/*.js scripts",
|
||
"jshint": "jshint lib/*.js lib/**/*.js --exclude lib/dotjs/**/*",
|
||
"prepublish": "npm run build && npm run bundle-all",
|
||
"test": "npm run jshint && npm run eslint && npm run test-ts && npm run build && npm run test-cov && if-node-version 4 npm run test-browser",
|
||
"test-browser": "del-cli .browser && npm run bundle-all && scripts/prepare-tests && npm run test-karma",
|
||
"test-cov": "nyc npm run test-spec",
|
||
"test-debug": "mocha spec/*.spec.js --debug-brk -R spec",
|
||
"test-fast": "AJV_FAST_TEST=true npm run test-spec",
|
||
"test-karma": "karma start --single-run --browsers PhantomJS",
|
||
"test-spec": "mocha spec/*.spec.js -R spec $(if-node-version 7 echo --harmony-async-await)",
|
||
"test-ts": "tsc --target ES5 --noImplicitAny lib/ajv.d.ts",
|
||
"watch": "watch 'npm run build' ./lib/dot"
|
||
},
|
||
"tonicExampleFilename": ".tonic_example.js",
|
||
"typings": "lib/ajv.d.ts",
|
||
"version": "5.5.2"
|
||
}
|