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
3
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.11.0 to 2.12.0

19

index.js

@@ -27,3 +27,20 @@ var genobj = require('generate-object-property')

} catch (err) {
var other = additionalSchemas[ptr] || additionalSchemas[ptr.replace(/^#/, '')]
var end = ptr.indexOf('#')
var other
// external reference
if (end !== 0) {
// fragment doesn't exist.
if (end === -1) {
other = additionalSchemas[ptr]
} else {
var ext = ptr.slice(0, end)
other = additionalSchemas[ext]
var fragment = ptr.slice(end).replace(/^#/, '')
try {
return jsonpointer.get(other, fragment)
} catch (err) {}
}
} else {
other = additionalSchemas[ptr]
}
return other || null

@@ -30,0 +47,0 @@ }

2

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

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

@@ -281,2 +281,32 @@ var tape = require('tape')

tape('top-level external schema', function(t) {
var defs = {
"string": {
type: "string"
},
"sex": {
type: "string",
enum: ["male", "female", "other"]
}
}
var schema = {
type: "object",
properties: {
"name": { $ref: "definitions.json#/string" },
"sex": { $ref: "definitions.json#/sex" }
},
required: ["name", "sex"]
}
var validate = validator(schema, {
schemas: {
"definitions.json": defs
}
})
t.ok(validate({name:"alice", sex:"female"}), 'is an object')
t.notOk(validate({name:"alice", sex: "bob"}), 'recognizes external schema')
t.notOk(validate({name:2, sex: "female"}), 'recognizes external schema')
t.end()
})
tape('nested required array decl', function(t) {

@@ -283,0 +313,0 @@ var schema = {

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