messages.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. export function newMessages() {
  2. return {
  3. default: 'Validation error on field %s',
  4. required: '%s is required',
  5. enum: '%s must be one of %s',
  6. whitespace: '%s cannot be empty',
  7. date: {
  8. format: '%s date %s is invalid for format %s',
  9. parse: '%s date could not be parsed, %s is invalid ',
  10. invalid: '%s date %s is invalid',
  11. },
  12. types: {
  13. string: '%s is not a %s',
  14. method: '%s is not a %s (function)',
  15. array: '%s is not an %s',
  16. object: '%s is not an %s',
  17. number: '%s is not a %s',
  18. date: '%s is not a %s',
  19. boolean: '%s is not a %s',
  20. integer: '%s is not an %s',
  21. float: '%s is not a %s',
  22. regexp: '%s is not a valid %s',
  23. email: '%s is not a valid %s',
  24. url: '%s is not a valid %s',
  25. hex: '%s is not a valid %s',
  26. },
  27. string: {
  28. len: '%s must be exactly %s characters',
  29. min: '%s must be at least %s characters',
  30. max: '%s cannot be longer than %s characters',
  31. range: '%s must be between %s and %s characters',
  32. },
  33. number: {
  34. len: '%s must equal %s',
  35. min: '%s cannot be less than %s',
  36. max: '%s cannot be greater than %s',
  37. range: '%s must be between %s and %s',
  38. },
  39. array: {
  40. len: '%s must be exactly %s in length',
  41. min: '%s cannot be less than %s in length',
  42. max: '%s cannot be greater than %s in length',
  43. range: '%s must be between %s and %s in length',
  44. },
  45. pattern: {
  46. mismatch: '%s value %s does not match pattern %s',
  47. },
  48. clone() {
  49. const cloned = JSON.parse(JSON.stringify(this));
  50. cloned.clone = this.clone;
  51. return cloned;
  52. },
  53. };
  54. }
  55. export const messages = newMessages();