Comparing version 2.0.0 to 2.0.1
@@ -22,2 +22,6 @@ { | ||
"url": "https://github.com/oleksiyk" | ||
}, | ||
{ | ||
"name": "Jurie-Jan Botha", | ||
"url": "https://github.com/juriejan" | ||
} | ||
@@ -31,3 +35,3 @@ ], | ||
"files": ["src/ZSchema.js", "src/ZSchema.min.js", "LICENSE", "README.md"], | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"dependencies": { | ||
@@ -37,3 +41,3 @@ "q": "0.9.7" | ||
"devDependencies": { | ||
"chai": "1.7.2", | ||
"chai": "1.8.1", | ||
"grunt": "0.4.1", | ||
@@ -43,3 +47,3 @@ "grunt-contrib-uglify": "0.2.4", | ||
"grunt-simple-mocha": "0.4.0", | ||
"mocha": "1.12.1", | ||
"mocha": "1.13.0", | ||
"uglify-js": "2.4.0" | ||
@@ -46,0 +50,0 @@ }, |
# z-schema validator | ||
[![NPM version](https://badge.fury.io/js/z-schema.png)](http://badge.fury.io/js/z-schema) | ||
[![Dependency Status](https://gemnasium.com/zaggino/z-schema.png)](https://gemnasium.com/zaggino/z-schema) | ||
@@ -23,3 +24,7 @@ JSON Schema validator for Node.js (draft4 version) | ||
```javascript | ||
zSchema.validate(json, schema) | ||
var ZSchema = require("z-schema"); | ||
``` | ||
```javascript | ||
ZSchema.validate(json, schema) | ||
.then(function(report){ | ||
@@ -36,3 +41,3 @@ // successful validation | ||
```javascript | ||
zSchema.validate(json, schema, function(err, report){ | ||
ZSchema.validate(json, schema, function(err, report){ | ||
if(err){ | ||
@@ -50,3 +55,3 @@ console.error(err.errors); | ||
```javascript | ||
var validator = new zSchema(); | ||
var validator = new ZSchema(); | ||
validator.validateSchema(schema) | ||
@@ -62,3 +67,3 @@ .then(function(report){ | ||
```javascript | ||
var validator = new zSchema(); | ||
var validator = new ZSchema(); | ||
validator.validateSchema(schema, function (err, report) { | ||
@@ -80,3 +85,3 @@ if (err) ... | ||
var fileContent = fs.readFileSync(__dirname + '/../json_schema_test_suite/remotes/integer.json', 'utf8'); | ||
zSchema.setRemoteReference('http://localhost:1234/integer.json', fileContent); | ||
ZSchema.setRemoteReference('http://localhost:1234/integer.json', fileContent); | ||
``` | ||
@@ -95,3 +100,3 @@ | ||
```javascript | ||
var validator = new zSchema(); | ||
var validator = new ZSchema(); | ||
validator.compileSchema(schema) | ||
@@ -105,3 +110,3 @@ .then(function(compiledSchema){ | ||
```javascript | ||
var validator = new zSchema(); | ||
var validator = new ZSchema(); | ||
validator.compileSchema(schema, function (err, compiledSchema) { | ||
@@ -116,3 +121,4 @@ assert.isUndefined(err); | ||
```javascript | ||
zSchema.validate(json, compiledSchema) | ||
var validator = new ZSchema(); | ||
validator.validate(json, compiledSchema) | ||
.then(function(report){ | ||
@@ -133,7 +139,9 @@ // ... | ||
```javascript | ||
zSchema.registerFormat('xstring', function (str) { | ||
var validator = new ZSchema(); | ||
ZSchema.registerFormat('xstring', function (str) { | ||
return str === 'xxx'; // return true/false as a result of validation | ||
}); | ||
zSchema.validate('xxx', { | ||
validator.validate('xxx', { | ||
'type': 'string', | ||
@@ -151,3 +159,3 @@ 'format': 'xstring' | ||
```javascript | ||
zSchema.registerFormat('xstring', function (str) { | ||
ZSchema.registerFormat('xstring', function (str) { | ||
return Q.delay(1000).thenResolve(return str === 'xxx'); // return a promise for validation result | ||
@@ -160,3 +168,3 @@ }); | ||
```javascript | ||
zSchema.registerFormat('xstring', function (str, callback) { | ||
ZSchema.registerFormat('xstring', function (str, callback) { | ||
setTimeout(function(){ | ||
@@ -171,3 +179,3 @@ callback(null, str === 'xxx'); | ||
```javascript | ||
zSchema.registerFormat('xstring', function (str) { | ||
ZSchema.registerFormat('xstring', function (str) { | ||
throw new Error('Bad, bad value!'); | ||
@@ -191,3 +199,3 @@ }); | ||
```javascript | ||
var validator = new zSchema({ | ||
var validator = new ZSchema({ | ||
option: true | ||
@@ -228,3 +236,3 @@ }); | ||
```javascript | ||
var validator = new zSchema({ | ||
var validator = new ZSchema({ | ||
strict: true | ||
@@ -231,0 +239,0 @@ }); |
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1602
0
238
1
86921
4