Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. module.exports = function (ajv, options) {
  3. if (!ajv._opts.allErrors) throw new Error('ajv-errors: Ajv option allErrors must be true');
  4. if (!ajv._opts.jsonPointers) {
  5. console.warn('ajv-errors: Ajv option jsonPointers changed to true');
  6. ajv._opts.jsonPointers = true;
  7. }
  8. ajv.addKeyword('errorMessage', {
  9. inline: require('./lib/dotjs/errorMessage'),
  10. statements: true,
  11. valid: true,
  12. errors: 'full',
  13. config: {
  14. KEYWORD_PROPERTY_PARAMS: {
  15. required: 'missingProperty',
  16. dependencies: 'property'
  17. },
  18. options: options || {}
  19. },
  20. metaSchema: {
  21. 'type': ['string', 'object'],
  22. properties: {
  23. properties: {$ref: '#/definitions/stringMap'},
  24. items: {$ref: '#/definitions/stringList'},
  25. required: {$ref: '#/definitions/stringOrMap'},
  26. dependencies: {$ref: '#/definitions/stringOrMap'}
  27. },
  28. additionalProperties: {'type': 'string'},
  29. definitions: {
  30. stringMap: {
  31. 'type': ['object'],
  32. additionalProperties: {'type': 'string'}
  33. },
  34. stringOrMap: {
  35. 'type': ['string', 'object'],
  36. additionalProperties: {'type': 'string'}
  37. },
  38. stringList: {
  39. 'type': ['array'],
  40. items: {'type': 'string'}
  41. }
  42. }
  43. }
  44. });
  45. return ajv;
  46. };