leepowelldev / mongoose-validator

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

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

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

juanmaia commented 9 years ago

+1

leepowelldev commented 9 years ago

Thank you for this - I have included all of your changes (with a couple of mods), and it will be released as part of 1.1.0.