leepowelldev / mongoose-validator

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

isInt and isFloat #43

Closed yuricamara closed 7 years ago

yuricamara commented 7 years ago

Hi,

For me, the validation always fails with isInt and isFloat validators even if the value is an integer or a float.

"mongoose": "4.11.5",
"mongoose-validator": "1.3.2"
leepowelldev commented 7 years ago

Hi - validator.js only validates against strings, so if you've got a schema type as a number then it'll fail. Changing it to a string should allow it to pass. However this might not suit your schema design. You could write your own isFloat/isInt custom validators to get around validator.js limitation and use other data structures.

yuricamara commented 7 years ago

Thank you @leepowellcouk !