You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
474 B
18 lines
474 B
'use strict'; |
|
|
|
module.exports = function defFunc(ajv) { |
|
defFunc.definition = { |
|
type: 'object', |
|
macro: function (schema, parentSchema) { |
|
if (!schema) return true; |
|
var properties = Object.keys(parentSchema.properties); |
|
if (properties.length == 0) return true; |
|
return {required: properties}; |
|
}, |
|
metaSchema: {type: 'boolean'}, |
|
dependencies: ['properties'] |
|
}; |
|
|
|
ajv.addKeyword('allRequired', defFunc.definition); |
|
return ajv; |
|
};
|
|
|