Skip to content

Commit

Permalink
Merge pull request ajv-validator#39 from rpl/fix/ajv-v7-and-v8
Browse files Browse the repository at this point in the history
fix: Applied minimum amount of changes to adapt ajv-merge-patch to ajv v7 and v8
  • Loading branch information
epoberezkin authored Aug 1, 2021
2 parents 84cbb85 + d965ab8 commit 7d02dc7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "4"
- "6"
- "12"
- "14"
after_script:
- coveralls < coverage/lcov.info
3 changes: 2 additions & 1 deletion keywords/add_keyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
var url = require('url');

module.exports = function (ajv, keyword, jsonPatch, patchSchema) {
ajv.addKeyword(keyword, {
ajv.addKeyword({
keyword: keyword,
macro: function (schema, parentSchema, it) {
var source = schema.source;
var patch = schema.with;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"json-merge-patch": "^0.2.3"
},
"devDependencies": {
"ajv": "^6.5.1",
"ajv": "^8.2.0",
"coveralls": "^2.11.12",
"eslint": "^3.3.0",
"if-node-version": "^1.0.0",
Expand All @@ -46,6 +46,6 @@
"pre-commit": "^1.1.3"
},
"peerDependencies": {
"ajv": ">=6.0.0"
"ajv": ">=8.0.0"
}
}
2 changes: 1 addition & 1 deletion spec/async.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('async schema loading', function() {
if (ref == 'obj.json') {
loadCount++;
var schema = {
"id": "obj.json#",
"$id": "obj.json#",
"type": "object",
"properties": { "p": { "type": "string" } },
"additionalProperties": false,
Expand Down
12 changes: 6 additions & 6 deletions spec/test_validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ module.exports = function (validate, keyword) {
var errs = validate.errors;
assert.equal(errs.length, 2);
assert.equal(errs[0].keyword, 'type');
assert.equal(errs[0].dataPath, '.q');
assert.equal(errs[0].schemaPath, '#/properties/q/type');
assert.equal(errs[0].schemaPath, '#/' + keyword + '/properties/q/type');
assert.equal(errs[0].instancePath, '/q');
assert.equal(errs[1].keyword, keyword);
assert.equal(errs[1].dataPath, '');
assert.equal(errs[1].instancePath, '');
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.equal(errs[0].schemaPath, '#/' + keyword + '/required');
assert.deepEqual(errs[0].params, { missingProperty: 'q' });
assert.equal(errs[0].instancePath, '');
assert.equal(errs[1].keyword, keyword);
assert.equal(errs[1].dataPath, '');
assert.equal(errs[1].schemaPath, '#/' + keyword);
assert.equal(errs[1].instancePath, '');
};

0 comments on commit 7d02dc7

Please sign in to comment.