master
Evgeny Poberezkin 2015-05-29 23:32:47 +01:00
parent ec1f473804
commit daf592adc4
5 changed files with 16 additions and 18 deletions

View File

@ -1,6 +1,4 @@
# jv
JSON schema validator
# ajv - Another JSON schema Validator
## TODO
@ -13,22 +11,22 @@ JSON schema validator
## Install
```
npm install jv
npm install ajv
```
## Usage
```
var jv = require('jv')(options);
var validate = jv.compile(schema);
var ajv = require('ajv')(options);
var validate = ajv.compile(schema);
var result = validate(data);
```
or
```
var result = jv.validate(schema, data);
var result = ajv.validate(schema, data);
```
Compiles and caches in both cases, so that the next time the same schema is used (not necessarily the same object instance) it won't be compiled again.

View File

@ -3,7 +3,7 @@
var compileSchema = require('./compile')
, stableStringify = require('json-stable-stringify')
module.exports = Jv;
module.exports = Ajv;
/**
* Creates validator instance.
@ -11,8 +11,8 @@ module.exports = Jv;
* @param {Object} opts optional options
* @return {Object} jv instance
*/
function Jv(opts) {
if (!(this instanceof Jv)) return new Jv(opts);
function Ajv(opts) {
if (!(this instanceof Ajv)) return new Ajv(opts);
var self = this;
this.opts = opts || {};

View File

@ -1,7 +1,7 @@
{
"name": "jv",
"version": "0.0.3",
"description": "JSON schema validator",
"name": "ajv",
"version": "0.0.4",
"description": "Another JSON schema Validator",
"main": "lib/jv.js",
"scripts": {
"test": "./node_modules/.bin/mocha --reporter=spec spec/*.spec.js"

View File

@ -19,9 +19,9 @@ var ONLY_RULES;
// ];
var Jv = require('../lib/jv')
, jv = Jv()
, fullJv = Jv({ allErrors: true, verbose: true });
var Ajv = require('../lib/ajv')
, ajv = Ajv()
, fullAjv = Ajv({ allErrors: true, verbose: true });
describe.only('JSON-Schema tests', function () {
var testsPath = path.join(__dirname, '..', TESTS_PATH);
@ -35,8 +35,8 @@ describe.only('JSON-Schema tests', function () {
// if (testSet.description != 'validation of URIs') return;
// describe(testSet.description, function() {
it(testSet.description, function() {
var validate = jv.compile(testSet.schema);
var fullValidate = fullJv.compile(testSet.schema);
var validate = ajv.compile(testSet.schema);
var fullValidate = fullAjv.compile(testSet.schema);
testSet.tests.forEach(function (test) {
// if (test.description != 'a valid date-time string') return;