-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpatch.js
37 lines (35 loc) · 922 Bytes
/
patch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
var addKeyword = require('./add_keyword');
var jsonPatch = require('fast-json-patch');
module.exports = function(ajv) {
addKeyword(ajv, '$patch', jsonPatch.applyPatch, {
"type": "array",
"items": {
"type": "object",
"required": [ "op", "path" ],
"properties": {
"op": { "type": "string" },
"path": { "type": "string", "format": "json-pointer" }
},
"anyOf": [
{
"properties": {
"op": { "enum": [ "add", "replace", "test" ] },
"value": {},
},
"required": [ "value" ]
},
{
"properties": { "op": { "enum": [ "remove" ] } }
},
{
"properties": {
"op": { "enum": [ "move", "copy" ] },
"from": { "type": "string", "format": "json-pointer" }
},
"required": [ "from" ]
}
]
}
});
};