Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-my-json-valid

Package Overview
Dependencies
Maintainers
6
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-my-json-valid - npm Package Compare versions

Comparing version 2.13.1 to 2.14.0

10

index.js

@@ -517,11 +517,19 @@ var genobj = require('generate-object-property')

if (node.minimum !== undefined) {
if (type !== 'number' && type !== 'integer') validate('if (%s) {', types.number(name))
validate('if (%s %s %d) {', name, node.exclusiveMinimum ? '<=' : '<', node.minimum)
error('is less than minimum')
validate('}')
if (type !== 'number' && type !== 'integer') validate('}')
}
if (node.maximum !== undefined) {
if (type !== 'number' && type !== 'integer') validate('if (%s) {', types.number(name))
validate('if (%s %s %d) {', name, node.exclusiveMaximum ? '>=' : '>', node.maximum)
error('is more than maximum')
validate('}')
if (type !== 'number' && type !== 'integer') validate('}')
}

@@ -544,2 +552,4 @@

('function validate(data) {')
// Since undefined is not a valid JSON value, we coerce to null and other checks will catch this
('if (data === undefined) data = null')
('validate.errors = null')

@@ -546,0 +556,0 @@ ('var errors = 0')

2

package.json
{
"name": "is-my-json-valid",
"version": "2.13.1",
"version": "2.14.0",
"description": "A JSONSchema validator that uses code generation to be extremely fast",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,2 +23,10 @@ var tape = require('tape')

tape('data is undefined', function (t) {
var validate = validator({type: 'string'})
t.notOk(validate(null))
t.notOk(validate(undefined))
t.end()
})
tape('advanced', function(t) {

@@ -198,2 +206,18 @@ var validate = validator(cosmic.schema)

tape('minimum/maximum number type', function(t) {
var validate = validator({
type: ['integer', 'null'],
minimum: 1,
maximum: 100
})
t.notOk(validate(-1))
t.notOk(validate(0))
t.ok(validate(null))
t.ok(validate(1))
t.ok(validate(100))
t.notOk(validate(101))
t.end()
})
tape('custom format', function(t) {

@@ -200,0 +224,0 @@ var validate = validator({

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