language.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. 'use strict';
  2. // Load modules
  3. // Declare internals
  4. const internals = {};
  5. exports.errors = {
  6. root: 'value',
  7. key: '"{{!label}}" ',
  8. messages: {
  9. wrapArrays: true
  10. },
  11. any: {
  12. unknown: 'is not allowed',
  13. invalid: 'contains an invalid value',
  14. empty: 'is not allowed to be empty',
  15. required: 'is required',
  16. allowOnly: 'must be one of {{valids}}',
  17. default: 'threw an error when running default method'
  18. },
  19. alternatives: {
  20. base: 'not matching any of the allowed alternatives',
  21. child: null
  22. },
  23. array: {
  24. base: 'must be an array',
  25. includes: 'at position {{pos}} does not match any of the allowed types',
  26. includesSingle: 'single value of "{{!label}}" does not match any of the allowed types',
  27. includesOne: 'at position {{pos}} fails because {{reason}}',
  28. includesOneSingle: 'single value of "{{!label}}" fails because {{reason}}',
  29. includesRequiredUnknowns: 'does not contain {{unknownMisses}} required value(s)',
  30. includesRequiredKnowns: 'does not contain {{knownMisses}}',
  31. includesRequiredBoth: 'does not contain {{knownMisses}} and {{unknownMisses}} other required value(s)',
  32. excludes: 'at position {{pos}} contains an excluded value',
  33. excludesSingle: 'single value of "{{!label}}" contains an excluded value',
  34. hasKnown: 'does not contain at least one required match for type "{{!patternLabel}}"',
  35. hasUnknown: 'does not contain at least one required match',
  36. min: 'must contain at least {{limit}} items',
  37. max: 'must contain less than or equal to {{limit}} items',
  38. length: 'must contain {{limit}} items',
  39. ordered: 'at position {{pos}} fails because {{reason}}',
  40. orderedLength: 'at position {{pos}} fails because array must contain at most {{limit}} items',
  41. ref: 'references "{{ref}}" which is not a positive integer',
  42. sparse: 'must not be a sparse array',
  43. unique: 'position {{pos}} contains a duplicate value'
  44. },
  45. boolean: {
  46. base: 'must be a boolean'
  47. },
  48. binary: {
  49. base: 'must be a buffer or a string',
  50. min: 'must be at least {{limit}} bytes',
  51. max: 'must be less than or equal to {{limit}} bytes',
  52. length: 'must be {{limit}} bytes'
  53. },
  54. date: {
  55. base: 'must be a number of milliseconds or valid date string',
  56. strict: 'must be a valid date',
  57. min: 'must be larger than or equal to "{{limit}}"',
  58. max: 'must be less than or equal to "{{limit}}"',
  59. less: 'must be less than "{{limit}}"',
  60. greater: 'must be greater than "{{limit}}"',
  61. isoDate: 'must be a valid ISO 8601 date',
  62. timestamp: {
  63. javascript: 'must be a valid timestamp or number of milliseconds',
  64. unix: 'must be a valid timestamp or number of seconds'
  65. },
  66. ref: 'references "{{ref}}" which is not a date'
  67. },
  68. function: {
  69. base: 'must be a Function',
  70. arity: 'must have an arity of {{n}}',
  71. minArity: 'must have an arity greater or equal to {{n}}',
  72. maxArity: 'must have an arity lesser or equal to {{n}}',
  73. ref: 'must be a Joi reference',
  74. class: 'must be a class'
  75. },
  76. lazy: {
  77. base: '!!schema error: lazy schema must be set',
  78. schema: '!!schema error: lazy schema function must return a schema'
  79. },
  80. object: {
  81. base: 'must be an object',
  82. child: '!!child "{{!child}}" fails because {{reason}}',
  83. min: 'must have at least {{limit}} children',
  84. max: 'must have less than or equal to {{limit}} children',
  85. length: 'must have {{limit}} children',
  86. allowUnknown: '!!"{{!child}}" is not allowed',
  87. with: '!!"{{mainWithLabel}}" missing required peer "{{peerWithLabel}}"',
  88. without: '!!"{{mainWithLabel}}" conflict with forbidden peer "{{peerWithLabel}}"',
  89. missing: 'must contain at least one of {{peersWithLabels}}',
  90. xor: 'contains a conflict between exclusive peers {{peersWithLabels}}',
  91. oxor: 'contains a conflict between optional exclusive peers {{peersWithLabels}}',
  92. and: 'contains {{presentWithLabels}} without its required peers {{missingWithLabels}}',
  93. nand: '!!"{{mainWithLabel}}" must not exist simultaneously with {{peersWithLabels}}',
  94. assert: '!!"{{ref}}" validation failed because "{{ref}}" failed to {{message}}',
  95. rename: {
  96. multiple: 'cannot rename child "{{from}}" because multiple renames are disabled and another key was already renamed to "{{to}}"',
  97. override: 'cannot rename child "{{from}}" because override is disabled and target "{{to}}" exists',
  98. regex: {
  99. multiple: 'cannot rename children {{from}} because multiple renames are disabled and another key was already renamed to "{{to}}"',
  100. override: 'cannot rename children {{from}} because override is disabled and target "{{to}}" exists'
  101. }
  102. },
  103. type: 'must be an instance of "{{type}}"',
  104. schema: 'must be a Joi instance'
  105. },
  106. number: {
  107. base: 'must be a number',
  108. unsafe: 'must be a safe number',
  109. min: 'must be larger than or equal to {{limit}}',
  110. max: 'must be less than or equal to {{limit}}',
  111. less: 'must be less than {{limit}}',
  112. greater: 'must be greater than {{limit}}',
  113. integer: 'must be an integer',
  114. negative: 'must be a negative number',
  115. positive: 'must be a positive number',
  116. precision: 'must have no more than {{limit}} decimal places',
  117. ref: 'references "{{ref}}" which is not a number',
  118. multiple: 'must be a multiple of {{multiple}}',
  119. port: 'must be a valid port'
  120. },
  121. string: {
  122. base: 'must be a string',
  123. min: 'length must be at least {{limit}} characters long',
  124. max: 'length must be less than or equal to {{limit}} characters long',
  125. length: 'length must be {{limit}} characters long',
  126. alphanum: 'must only contain alpha-numeric characters',
  127. token: 'must only contain alpha-numeric and underscore characters',
  128. regex: {
  129. base: 'with value "{{!value}}" fails to match the required pattern: {{pattern}}',
  130. name: 'with value "{{!value}}" fails to match the {{name}} pattern',
  131. invert: {
  132. base: 'with value "{{!value}}" matches the inverted pattern: {{pattern}}',
  133. name: 'with value "{{!value}}" matches the inverted {{name}} pattern'
  134. }
  135. },
  136. email: 'must be a valid email',
  137. uri: 'must be a valid uri',
  138. uriRelativeOnly: 'must be a valid relative uri',
  139. uriCustomScheme: 'must be a valid uri with a scheme matching the {{scheme}} pattern',
  140. isoDate: 'must be a valid ISO 8601 date',
  141. guid: 'must be a valid GUID',
  142. hex: 'must only contain hexadecimal characters',
  143. hexAlign: 'hex decoded representation must be byte aligned',
  144. base64: 'must be a valid base64 string',
  145. dataUri: 'must be a valid dataUri string',
  146. hostname: 'must be a valid hostname',
  147. normalize: 'must be unicode normalized in the {{form}} form',
  148. lowercase: 'must only contain lowercase characters',
  149. uppercase: 'must only contain uppercase characters',
  150. trim: 'must not have leading or trailing whitespace',
  151. creditCard: 'must be a credit card',
  152. ref: 'references "{{ref}}" which is not a number',
  153. ip: 'must be a valid ip address with a {{cidr}} CIDR',
  154. ipVersion: 'must be a valid ip address of one of the following versions {{version}} with a {{cidr}} CIDR'
  155. },
  156. symbol: {
  157. base: 'must be a symbol',
  158. map: 'must be one of {{map}}'
  159. }
  160. };