validator.js
validator.js copied to clipboard
Undefined min, max, gt, lt values taken into consideration during validation
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
Can you assign it to me?