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

ajv-merge-patch

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-merge-patch - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

2

keywords/add_keyword.js

@@ -12,3 +12,3 @@ 'use strict';

if (patch.$ref) patch = getSchema(patch.$ref);
jsonPatch.apply(source, patch, true);
jsonPatch.call(null, source, patch, true);
return source;

@@ -15,0 +15,0 @@

@@ -7,3 +7,3 @@ 'use strict';

module.exports = function(ajv) {
addKeyword(ajv, '$merge', jsonMergePatch, { "type": "object" });
addKeyword(ajv, '$merge', jsonMergePatch.apply, { "type": "object" });
};
'use strict';
var addKeyword = require('./add_keyword');
var jsonPatch = require('fast-json-patch/src/json-patch');
var jsonPatch = require('fast-json-patch');
module.exports = function(ajv) {
addKeyword(ajv, '$patch', jsonPatch, {
addKeyword(ajv, '$patch', jsonPatch.applyPatch, {
"type": "array",

@@ -9,0 +9,0 @@ "items": {

{
"name": "ajv-merge-patch",
"version": "4.0.0",
"version": "4.1.0",
"description": "$merge and $patch keywords for Ajv JSON-Schema validator to extend schemas",

@@ -36,3 +36,3 @@ "main": "index.js",

"dependencies": {
"fast-json-patch": "^1.0.0",
"fast-json-patch": "^2.0.6",
"json-merge-patch": "^0.2.3"

@@ -39,0 +39,0 @@ },

@@ -78,3 +78,3 @@ # ajv-merge-patch

In the majority of cases `$merge` format is easier to understand and to maintain. `$patch` can be used for extensions and changes that cannot be expressed using `$merge`.
In the majority of cases `$merge` format is easier to understand and to maintain. `$patch` can be used for extensions and changes that cannot be expressed using `$merge`, e.g. [Adding an array value](https://tools.ietf.org/html/rfc6902#page-18).

@@ -81,0 +81,0 @@ `with` property in keywords can also be a reference to a part of some schema, in which case the resolved value will be used rather than the actual object with property `$ref`.

@@ -23,3 +23,4 @@ 'use strict';

"with": {
"properties": { "q": { "type": "number" } }
"properties": { "q": { "type": "number" } },
"required": [ "q" ]
}

@@ -39,3 +40,4 @@ }

"with": [
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } }
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } },
{ "op": "add", "path": "/required/-", "value": "q" }
]

@@ -64,3 +66,4 @@ }

"properties": { "p": { "type": "string" } },
"additionalProperties": false
"additionalProperties": false,
"required": [ "p" ]
};

@@ -67,0 +70,0 @@ return Promise.resolve(schema);

@@ -29,3 +29,4 @@ 'use strict';

"with": {
"properties": { "q": { "type": "number" } }
"properties": { "q": { "type": "number" } },
"required": [ "q" ]
}

@@ -57,3 +58,4 @@ }

"with": {
"properties": { "q": { "type": "number" } }
"properties": { "q": { "type": "number" } },
"required": [ "q" ]
}

@@ -84,3 +86,4 @@ }

"with": {
"properties": { "q": { "type": "number" } }
"properties": { "q": { "type": "number" } },
"required": [ "q" ]
}

@@ -102,3 +105,4 @@ }

"properties": { "p": { "type": "string" } },
"additionalProperties": false
"additionalProperties": false,
"required": [ "p" ]
};

@@ -109,3 +113,4 @@

"properties": { "q": { "type": "number" } },
"additionalProperties": false
"additionalProperties": false,
"required": [ "q" ]
};

@@ -146,3 +151,4 @@

"properties": { "q": { "type": "number" } },
"additionalProperties": false
"additionalProperties": false,
"required" : [ "q" ]
}

@@ -149,0 +155,0 @@ },

@@ -26,6 +26,8 @@ 'use strict';

"properties": { "p": { "type": "string" } },
"additionalProperties": false
"additionalProperties": false,
"required": [ "p" ]
},
"with": [
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } }
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } },
{ "op": "add", "path": "/required/-", "value": "q" }
]

@@ -48,3 +50,4 @@ }

"properties": { "p": { "type": "string" } },
"additionalProperties": false
"additionalProperties": false,
"required": [ "p" ]
};

@@ -58,3 +61,4 @@

"with": [
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } }
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } },
{ "op": "add", "path": "/required/-", "value": "q" }
]

@@ -79,3 +83,4 @@ }

"properties": { "p": { "type": "string" } },
"additionalProperties": false
"additionalProperties": false,
"required": [ "p" ]
}

@@ -86,3 +91,4 @@ },

"with": [
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } }
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } },
{ "op": "add", "path": "/required/-", "value": "q" }
]

@@ -89,0 +95,0 @@ }

@@ -7,2 +7,4 @@ 'use strict';

assert.strictEqual(validate({ p: 'abc', q: 1 }), true);
// property q should be a number
assert.strictEqual(validate({ p: 'foo', q: 'bar' }), false);

@@ -17,2 +19,14 @@ var errs = validate.errors;

assert.equal(errs[1].schemaPath, '#/' + keyword);
// an object without q should fail
assert.strictEqual(validate({ p: 'foo' }), false);
errs = validate.errors;
assert.equal(errs.length, 2);
assert.equal(errs[0].keyword, 'required');
assert.equal(errs[0].dataPath, '');
assert.equal(errs[0].schemaPath, '#/required');
assert.deepEqual(errs[0].params, { missingProperty: 'q' });
assert.equal(errs[1].keyword, keyword);
assert.equal(errs[1].dataPath, '');
assert.equal(errs[1].schemaPath, '#/' + keyword);
};
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