patternGroups.js 947 B

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. var META_SCHEMA_ID = 'http://json-schema.org/draft-06/schema';
  3. module.exports = function (ajv) {
  4. var defaultMeta = ajv._opts.defaultMeta;
  5. var metaSchemaRef = typeof defaultMeta == 'string'
  6. ? { $ref: defaultMeta }
  7. : ajv.getSchema(META_SCHEMA_ID)
  8. ? { $ref: META_SCHEMA_ID }
  9. : {};
  10. ajv.addKeyword('patternGroups', {
  11. // implemented in properties.jst
  12. metaSchema: {
  13. type: 'object',
  14. additionalProperties: {
  15. type: 'object',
  16. required: [ 'schema' ],
  17. properties: {
  18. maximum: {
  19. type: 'integer',
  20. minimum: 0
  21. },
  22. minimum: {
  23. type: 'integer',
  24. minimum: 0
  25. },
  26. schema: metaSchemaRef
  27. },
  28. additionalProperties: false
  29. }
  30. }
  31. });
  32. ajv.RULES.all.properties.implements.push('patternGroups');
  33. };