jsonschema
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -515,3 +515,3 @@ 'use strict'; | ||
argument: schema.pattern, | ||
message: "does not match pattern " + JSON.stringify(schema.pattern), | ||
message: "does not match pattern " + JSON.stringify(schema.pattern.toString()), | ||
}); | ||
@@ -518,0 +518,0 @@ } |
@@ -145,3 +145,3 @@ 'use strict'; | ||
}, | ||
'style': /\s*(.+?):\s*([^;]+);?/g, | ||
'style': /\s*(.+?):\s*([^;]+);?/, | ||
'phone': /^\+(?:[0-9] ?){6,14}[0-9]$/ | ||
@@ -148,0 +148,0 @@ }; |
@@ -39,2 +39,3 @@ /* | ||
toString(): string; | ||
stack: string; | ||
} | ||
@@ -63,3 +64,3 @@ | ||
minLength?: number | ||
pattern?: string | ||
pattern?: string | RegExp | ||
additionalItems?: boolean | Schema | ||
@@ -66,0 +67,0 @@ items?: Schema | Schema[] |
{ | ||
"author": "Tom de Grunt <tom@degrunt.nl>", | ||
"name": "jsonschema", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
121
README.md
@@ -19,7 +19,7 @@ [![Build Status](https://secure.travis-ci.org/tdegrunt/jsonschema.svg)](http://travis-ci.org/tdegrunt/jsonschema) | ||
```javascript | ||
var Validator = require('jsonschema').Validator; | ||
var v = new Validator(); | ||
var instance = 4; | ||
var schema = {"type": "number"}; | ||
console.log(v.validate(instance, schema)); | ||
var Validator = require('jsonschema').Validator; | ||
var v = new Validator(); | ||
var instance = 4; | ||
var schema = {"type": "number"}; | ||
console.log(v.validate(instance, schema)); | ||
``` | ||
@@ -30,4 +30,4 @@ | ||
```javascript | ||
var validate = require('jsonschema').validate; | ||
console.log(validate(4, {"type": "number"})); | ||
var validate = require('jsonschema').validate; | ||
console.log(validate(4, {"type": "number"})); | ||
``` | ||
@@ -38,45 +38,45 @@ | ||
```javascript | ||
var Validator = require('jsonschema').Validator; | ||
var v = new Validator(); | ||
var Validator = require('jsonschema').Validator; | ||
var v = new Validator(); | ||
// Address, to be embedded on Person | ||
var addressSchema = { | ||
"id": "/SimpleAddress", | ||
"type": "object", | ||
"properties": { | ||
"lines": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
}, | ||
"zip": {"type": "string"}, | ||
"city": {"type": "string"}, | ||
"country": {"type": "string"} | ||
// Address, to be embedded on Person | ||
var addressSchema = { | ||
"id": "/SimpleAddress", | ||
"type": "object", | ||
"properties": { | ||
"lines": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
}, | ||
"required": ["country"] | ||
}; | ||
"zip": {"type": "string"}, | ||
"city": {"type": "string"}, | ||
"country": {"type": "string"} | ||
}, | ||
"required": ["country"] | ||
}; | ||
// Person | ||
var schema = { | ||
"id": "/SimplePerson", | ||
"type": "object", | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"address": {"$ref": "/SimpleAddress"}, | ||
"votes": {"type": "integer", "minimum": 1} | ||
} | ||
}; | ||
// Person | ||
var schema = { | ||
"id": "/SimplePerson", | ||
"type": "object", | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"address": {"$ref": "/SimpleAddress"}, | ||
"votes": {"type": "integer", "minimum": 1} | ||
} | ||
}; | ||
var p = { | ||
"name": "Barack Obama", | ||
"address": { | ||
"lines": [ "1600 Pennsylvania Avenue Northwest" ], | ||
"zip": "DC 20500", | ||
"city": "Washington", | ||
"country": "USA" | ||
}, | ||
"votes": "lots" | ||
}; | ||
var p = { | ||
"name": "Barack Obama", | ||
"address": { | ||
"lines": [ "1600 Pennsylvania Avenue Northwest" ], | ||
"zip": "DC 20500", | ||
"city": "Washington", | ||
"country": "USA" | ||
}, | ||
"votes": "lots" | ||
}; | ||
v.addSchema(addressSchema, '/SimpleAddress'); | ||
console.log(v.validate(p, schema)); | ||
v.addSchema(addressSchema, '/SimpleAddress'); | ||
console.log(v.validate(p, schema)); | ||
``` | ||
@@ -116,3 +116,3 @@ | ||
``` | ||
```javascript | ||
Validator.prototype.customFormats.myFormat = function(input) { | ||
@@ -165,14 +165,14 @@ return input === 'myFormat'; | ||
```javascript | ||
var Validator = require('jsonschema').Validator; | ||
var v = new Validator(); | ||
v.addSchema(initialSchema); | ||
function importNextSchema(){ | ||
var nextSchema = v.unresolvedRefs.shift(); | ||
if(!nextSchema){ done(); return; } | ||
databaseGet(nextSchema, function(schema){ | ||
v.addSchema(schema); | ||
importNextSchema(); | ||
}); | ||
} | ||
importNextSchema(); | ||
var Validator = require('jsonschema').Validator; | ||
var v = new Validator(); | ||
v.addSchema(initialSchema); | ||
function importNextSchema(){ | ||
var nextSchema = v.unresolvedRefs.shift(); | ||
if(!nextSchema){ done(); return; } | ||
databaseGet(nextSchema, function(schema){ | ||
v.addSchema(schema); | ||
importNextSchema(); | ||
}); | ||
} | ||
importNextSchema(); | ||
``` | ||
@@ -183,3 +183,4 @@ | ||
```const coercionHook = function (instance, property, schema, options, ctx) { | ||
```javascript | ||
const coercionHook = function (instance, property, schema, options, ctx) { | ||
var value = instance[property]; | ||
@@ -236,3 +237,3 @@ | ||
Copyright (C) 2012-2015 Tom de Grunt <tom@degrunt.nl> | ||
Copyright (C) 2012-2019 Tom de Grunt <tom@degrunt.nl> | ||
@@ -239,0 +240,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of |
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
1549
250
63435