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

add more options in isLength - feature request

Open guicompeng opened this issue 2 years ago • 3 comments

Currently the options for isLength are min and max only. I believe there could be more options. I'm needing the field size to be exactly 11 or 14 or 16. For now I'm using min 11 and max 16 but in my program the length values (12, 13, 15) should not be accepted. a new option can be:

exact: {11, 14, 16} or size: {11, 14, 16}

Do you think this change adding more options would be a good thing?

guicompeng avatar Mar 09 '22 17:03 guicompeng

Hello, as a user, I think this is a really useful feature, I am currently working in this issue, to create a function that does this, I will create a Pull Request later when I complete the feature :)

Carlos-Gaxiola avatar Mar 09 '22 23:03 Carlos-Gaxiola

Hello, I have added the required feature. If the string length falls in the range and if exact number/array/object is mentioned, then exact conditions are checked. If not provided, then true is returned is len>=min & len<=max and false is returned is not in range [min, max]. Thanks for giving me a chance to contribute :) PR#2019 - https://github.com/validatorjs/validator.js/pull/2019

bevatsal1122 avatar Aug 06 '22 21:08 bevatsal1122

Heyy @rubiin !! This additional feature is been added in PR https://github.com/validatorjs/validator.js/pull/2019. It would be great if you could have a look.

bevatsal1122 avatar Aug 14 '22 21:08 bevatsal1122

@guicompeng I want to know if this issue is still open for me to work on it. Thanks and look forward to hearing from you.

NwaforAugustine321 avatar May 12 '23 20:05 NwaforAugustine321