Comparing version 0.6.13 to 0.6.14
@@ -83,3 +83,3 @@ 'use strict'; | ||
* @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`. | ||
* @return {Function} compiled schema with method `validate` that accepts `data`. | ||
* @return {Function} compiled schema function. | ||
*/ | ||
@@ -98,2 +98,18 @@ function addSchema(schema, key, _skipValidation) { | ||
/** | ||
* Add schema that will be used to validate other schemas | ||
* removeAdditional option is alway set to false | ||
* @param {Object} schema | ||
* @param {String} key optional schema key | ||
* @return {Function} compiled schema | ||
*/ | ||
function addMetaSchema(schema, key, _skipValidation) { | ||
var currentRemoveAdditional = self.opts.removeAdditional; | ||
self.opts.removeAdditional = false; | ||
var validate = addSchema(schema, META_SCHEMA_ID, true); | ||
self.opts.removeAdditional = currentRemoveAdditional; | ||
return validate; | ||
} | ||
/** | ||
* Validate schema | ||
@@ -194,8 +210,4 @@ * @param {Object} schema schema to validate | ||
function addInitialSchemas() { | ||
if (self.opts.meta !== false) { | ||
var currentRemoveAdditional = self.opts.removeAdditional; | ||
self.opts.removeAdditional = false; | ||
addSchema(require('./refs/json-schema-draft-04.json'), META_SCHEMA_ID, true); | ||
self.opts.removeAdditional = currentRemoveAdditional; | ||
} | ||
if (self.opts.meta !== false) | ||
addMetaSchema(require('./refs/json-schema-draft-04.json'), META_SCHEMA_ID); | ||
@@ -202,0 +214,0 @@ var optsSchemas = self.opts.schemas; |
{ | ||
"name": "ajv", | ||
"version": "0.6.13", | ||
"version": "0.6.14", | ||
"description": "Another JSON Schema Validator", | ||
@@ -5,0 +5,0 @@ "main": "lib/ajv.js", |
@@ -42,2 +42,4 @@ # ajv - Another JSON Schema Validator | ||
The fastest validation call: | ||
``` | ||
@@ -51,3 +53,3 @@ var Ajv = require('ajv'); | ||
or | ||
or with less code | ||
@@ -73,3 +75,5 @@ ``` | ||
The best performance is achieved when using compiled functions (there is no additional function call). | ||
## Using in browser | ||
@@ -165,2 +169,9 @@ | ||
##### .addMetaSchema(Object schema [, String key]) -> Function | ||
Adds meta schema 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). | ||
There is no need to explicitely add draft 4 meta schema (http://json-schema.org/draft-04/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`. | ||
##### .validateSchema(Object schema) -> Boolean | ||
@@ -167,0 +178,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
410678
169
10876
309