messages.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * The default built-in validator error messages. These may be customized.
  3. *
  4. * // customize within each schema or globally like so
  5. * var mongoose = require('mongoose');
  6. * mongoose.Error.messages.String.enum = "Your custom message for {PATH}.";
  7. *
  8. * As you might have noticed, error messages support basic templating
  9. *
  10. * - `{PATH}` is replaced with the invalid document path
  11. * - `{VALUE}` is replaced with the invalid value
  12. * - `{TYPE}` is replaced with the validator type such as "regexp", "min", or "user defined"
  13. * - `{MIN}` is replaced with the declared min value for the Number.min validator
  14. * - `{MAX}` is replaced with the declared max value for the Number.max validator
  15. *
  16. * Click the "show code" link below to see all defaults.
  17. *
  18. * @property messages
  19. * @receiver MongooseError
  20. * @api public
  21. */
  22. var msg = module.exports = exports = {};
  23. msg.general = {};
  24. msg.general.default = "Validator failed for path `{PATH}` with value `{VALUE}`";
  25. msg.general.required = "Path `{PATH}` is required.";
  26. msg.Number = {};
  27. msg.Number.min = "Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).";
  28. msg.Number.max = "Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).";
  29. msg.Date = {};
  30. msg.Date.min = "Path `{PATH}` ({VALUE}) is before minimum allowed value ({MIN}).";
  31. msg.Date.max = "Path `{PATH}` ({VALUE}) is after maximum allowed value ({MAX}).";
  32. msg.String = {};
  33. msg.String.enum = "`{VALUE}` is not a valid enum value for path `{PATH}`.";
  34. msg.String.match = "Path `{PATH}` is invalid ({VALUE}).";
  35. msg.String.minlength = "Path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).";
  36. msg.String.maxlength = "Path `{PATH}` (`{VALUE}`) is longer than the maximum allowed length ({MAXLENGTH}).";