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

4 years ago
  1. 'use strict';
  2. module.exports = function defFunc(ajv) {
  3. defFunc.definition = {
  4. type: 'object',
  5. macro: function (schema, parentSchema) {
  6. if (!schema) return true;
  7. var properties = Object.keys(parentSchema.properties);
  8. if (properties.length == 0) return true;
  9. return {required: properties};
  10. },
  11. metaSchema: {type: 'boolean'},
  12. dependencies: ['properties']
  13. };
  14. ajv.addKeyword('allRequired', defFunc.definition);
  15. return ajv;
  16. };