Socket
Socket
Sign inDemoInstall

ajv

Package Overview
Dependencies
Maintainers
1
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv - npm Package Compare versions

Comparing version 0.5.7 to 0.5.8

lib/cache.js

9

lib/ajv.js

@@ -5,2 +5,3 @@ 'use strict';

, resolve = require('./compile/resolve')
, Cache = require('./cache')
, stableStringify = require('json-stable-stringify')

@@ -31,4 +32,4 @@ , formats = require('./compile/formats')

this._refs = {};
this._byJson = {};
this._formats = formats(this.opts.format);
this._cache = this.opts.cache || new Cache;

@@ -141,3 +142,4 @@ // this is done on purpose, so that methods are bound to the instance

var str = stableStringify(schema);
if (self._byJson[str]) return self._byJson[str];
var cached = self._cache.get(str);
if (cached) return cached;

@@ -157,3 +159,4 @@ var id = resolve.normalizeId(schema.id);

var validate = self._refs[id] = self._byJson[str] = compileSchema.call(self, schema);
var validate = self._refs[id] = compileSchema.call(self, schema);
self._cache.put(str, validate);

@@ -160,0 +163,0 @@ return validate;

{
"name": "ajv",
"version": "0.5.7",
"version": "0.5.8",
"description": "Another JSON schema Validator",

@@ -5,0 +5,0 @@ "main": "lib/ajv.js",

@@ -116,9 +116,11 @@ # ajv - Another JSON Schema Validator

Validates schema.
Validates schema. This method should be used to validate schemas rather than `validate` due to the inconsistency of `uri` format in JSON-Schema standart.
By default this method is called automatically when the schema is added, so you rarely need to use it directly.
If schema doesn't have `$schema` property it is validated against draft 4 meta-schema (option `meta` should not be false).
If schema has `$schema` property than the schema with this id (should be previously added) is used to validate passed schema.
If schema has `$schema` property then the schema with this id (should be previously added) is used to validate passed schema.
Errors are available at `ajv.errors`.
Errors will be available at `ajv.errors`.

@@ -163,2 +165,3 @@

- _beautify_: format the generated function with [js-beautify](https://github.com/beautify-web/js-beautify) (the validating function is generated without line-breaks). `npm install js-beautify` to use this option. `true` or js-beautify options can be passed.
- _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. In 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)` and `get(key)`.

@@ -207,1 +210,6 @@

Errors are set to `null` if there are no errors (previously empty array).
## License
[MIT](https://github.com/epoberezkin/ajv/blob/master/LICENSE)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc