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