validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

Undefined min, max, gt, lt values taken into consideration during validation

Open jrtitus opened this issue 2 years ago • 1 comments

Describe the bug Properties of an object are considered undefined unless set, but an explicit undefined value is taken into consideration when determining if isInt or isFloat succeeds due to the use of hasOwnProperty.

https://github.com/validatorjs/validator.js/blob/b958bd7d1026a434ad3bf90064d3dcb8b775f1a9/src/lib/isInt.js#L18-L21

Examples

import { isInt } from 'validator'

isInt("5") // => true
isInt("5", {min: 0, max: 10}) // => true
isInt("5", { }} // => true
isInt("5", {min: undefined, max: undefined}) // => false

Maybe it's just my opinion, but I think that last one should also return true.

Additional context Validator.js version: [email protected] Node.js version: Node 18.17.1 OS platform: linux

jrtitus avatar Oct 20 '23 20:10 jrtitus

Can you assign it to me?

dk172923 avatar Oct 21 '23 02:10 dk172923