UNPKG

824 BJavaScriptView Raw
1/*!
2 * Copyright (c) 2019 Digital Bazaar, Inc. All rights reserved.
3 */
4const bedrock = require('bedrock');
5
6const schema = {
7 title: 'JSON Patch',
8 type: 'array',
9 minItems: 1,
10 items: {
11 type: 'object',
12 required: ['op', 'path'],
13 // FIXME: more strictly validate properties based on value of `op`
14 properties: {
15 op: {
16 type: 'string',
17 enum: ['add', 'copy', 'move', 'remove', 'replace', 'test']
18 },
19 from: {
20 type: 'string',
21 },
22 path: {
23 type: 'string',
24 },
25 value: {
26 //type: ['number', 'string', 'boolean', 'object', 'array'],
27 }
28 },
29 additionalProperties: false
30 }
31};
32
33module.exports = function(extend) {
34 if(extend) {
35 return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
36 }
37 return schema;
38};