leepowelldev / mongoose-validator

Validators for mongoose models utilising validator.js
MIT License
379 stars 43 forks source link

Allow use of arguments as part of custom error message. #27

Closed ericsaboia closed 9 years ago

ericsaboia commented 9 years ago

When using custom global error message, use of arguments as part of message would be great.

example:

validate.defaultErrorMessages.isLength = "{{PATH}} should be between {{args.0}} and {{args.1}} characters";

var nameValidator = [
  validate({
    validator: 'isLength',
    arguments: [5, 40],
  })
];

would be replaced by name should be between 5 and 40 characters