is-my-json-valid
Advanced tools
Comparing version 1.3.9 to 1.4.0
@@ -122,4 +122,4 @@ var normalize = require('./normalize') | ||
if (node.minimum !== undefined) { | ||
validate('if (%s < %d) {', name, node.minimum) | ||
error('must be more than '+node.minimum) | ||
validate('if (%s %s %d) {', name, node.exclusiveMinimum ? '<=' : '<', node.minimum) | ||
error('must be more than ' + (node.exclusiveMinimum ? '' : 'or equal to ') +node.minimum) | ||
validate('}') | ||
@@ -129,4 +129,4 @@ } | ||
if (node.maximum !== undefined) { | ||
validate('if (%s > %d) {', name, node.maximum) | ||
error('must be less than '+node.maximum) | ||
validate('if (%s %s %d) {', name, node.exclusiveMaximum ? '>=' : '>', node.maximum) | ||
error('must be less than ' + (node.exclusiveMaximum ? '' : 'or equal to ') +node.maximum) | ||
validate('}') | ||
@@ -133,0 +133,0 @@ } |
@@ -40,2 +40,5 @@ var xtend = require('xtend') | ||
if (root.minimum !== undefined) root.exclusiveMinimum = !!node.exclusiveMinimum | ||
if (root.maximum !== undefined) root.exclusiveMaximum = !!node.exclusiveMaximum | ||
if (root.pattern) root.pattern = root.pattern.replace(/(^\/)|(\/$)/g, '') | ||
@@ -74,2 +77,2 @@ | ||
return tree | ||
} | ||
} |
{ | ||
"name": "is-my-json-valid", | ||
"version": "1.3.9", | ||
"version": "1.4.0", | ||
"description": "A JSONSchema / orderly validator that uses code generation to be extremely fast", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -133,1 +133,22 @@ var tape = require('tape') | ||
}) | ||
tape('exclusiveMinimum/exclusiveMaximum', function(t) { | ||
var validate = validator({ | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'number', | ||
minimum: 10, | ||
maximum: 20, | ||
exclusiveMinimum: true, | ||
exclusiveMaximum: true | ||
} | ||
} | ||
}) | ||
t.notOk(validate({foo:10})) | ||
t.ok(validate({foo:11})) | ||
t.notOk(validate({foo:20})) | ||
t.ok(validate({foo:19})) | ||
t.end() | ||
}) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
22898
516
1