Projekt

Obecné

Profil

Stáhnout (1.31 KB) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
module.exports = function (ajv, options) {
4
  if (!ajv._opts.allErrors) throw new Error('ajv-errors: Ajv option allErrors must be true');
5
  if (!ajv._opts.jsonPointers) {
6
    console.warn('ajv-errors: Ajv option jsonPointers changed to true');
7
    ajv._opts.jsonPointers = true;
8
  }
9

    
10
  ajv.addKeyword('errorMessage', {
11
    inline: require('./lib/dotjs/errorMessage'),
12
    statements: true,
13
    valid: true,
14
    errors: 'full',
15
    config: {
16
      KEYWORD_PROPERTY_PARAMS: {
17
        required: 'missingProperty',
18
        dependencies: 'property'
19
      },
20
      options: options || {}
21
    },
22
    metaSchema: {
23
      'type': ['string', 'object'],
24
      properties: {
25
        properties: {$ref: '#/definitions/stringMap'},
26
        items: {$ref: '#/definitions/stringList'},
27
        required: {$ref: '#/definitions/stringOrMap'},
28
        dependencies: {$ref: '#/definitions/stringOrMap'}
29
      },
30
      additionalProperties: {'type': 'string'},
31
      definitions: {
32
        stringMap: {
33
          'type': ['object'],
34
          additionalProperties: {'type': 'string'}
35
        },
36
        stringOrMap: {
37
          'type': ['string', 'object'],
38
          additionalProperties: {'type': 'string'}
39
        },
40
        stringList: {
41
          'type': ['array'],
42
          items: {'type': 'string'}
43
        }
44
      }
45
    }
46
  });
47
  return ajv;
48
};
(3-3/4)