language.js 7.6 KB

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