leepowelldev / mongoose-validator

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

Added ability to keep orginal value type in custom validation methods #13

Closed toddbluhm closed 10 years ago

toddbluhm commented 10 years ago

When trying to use a custom validation method on a non-string type, validator would try to force the type to a string, which made validation checking on non-string types very difficult. This PR adds the ability to pass an option called: "keepOriginalValue: true" (just like passIfEmpty) and this will not force "this.str" inside custom validation functions to a string, but leave it untouched. Leaving it untouched allows for custom type checking as well as still being able to chain it with other mongoose-validators. Tests included and passing.

leepowelldev commented 10 years ago

Thanks. I'll review asap...

igorescobar commented 10 years ago

seems like this repo needs help. :+1:

leepowelldev commented 10 years ago

This has been fixed for 1.0.0 - in custom validators the original value will never be cast as a string.