validatorjs / validator.js

String validation
MIT License
23.01k stars 2.29k forks source link

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

Closed jrtitus closed 2 weeks ago

jrtitus commented 11 months ago

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: validator@13.11.0 Node.js version: Node 18.17.1 OS platform: linux

dk172923 commented 11 months ago

Can you assign it to me?

pano9000 commented 2 weeks ago

closed by #2416