validatorjs / validator.js

String validation
MIT License
23.12k stars 2.31k forks source link

isDate raise an exception on "2024-08-" #2427

Closed vit1251 closed 2 months ago

vit1251 commented 4 months ago

Describe the bug

isDate raise an exception on "2024-" isDate raise an exception on "2024-08-"

Validation error: err = TypeError: Cannot read properties of undefined (reading 'length')

Additional context Validator.js version: 13.12.0 Node.js version: 20.14.0 OS platform: linux

TDKhang commented 2 months ago

With format = "YYYY-MM-DD", I also get the error when input is "2024", but "202" works fine

profnandaa commented 2 months ago

PR welcome.

pano9000 commented 2 months ago

can confirm error is thrown with the following

2024
2024-08

these correctly return false however

2024-
2024-08-
2024-08-09-

edit: error got introduced with https://github.com/validatorjs/validator.js/pull/2257

I'll try to take a look and (hopfeully fix :-)) at this tomorrow

profnandaa commented 2 months ago

Thanks!

On Sun, Aug 25, 2024, 04:14 Panagiotis Papadopoulos < @.***> wrote:

can confirm error is thrown with the following

2024 2024-08

these correctly return false however

2024- 2024-08- 2024-08-09-

I'll try to take a look and (hopfeully fix :-)) at this tomorrow

— Reply to this email directly, view it on GitHub https://github.com/validatorjs/validator.js/issues/2427#issuecomment-2308607424 or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7ZEIPGLE3Y4ZIOSOD5O3ZTEVXVBFKMF2HI4TJMJ2XIZLTSWBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVEZTIMJVHAZTIMJRURXGC3LFVFUGC427NRQWEZLMQKSXMYLMOVS2UMJQGY3DSOBUHA2TTJDOMFWWLKLIMFZV63DBMJSWZLDTOVRGUZLDORPXI6LQMWWES43TOVSUG33NNVSW45FGORXXA2LDOOKIFJDUPFYGLKTSMVYG643JORXXE6NFOZQWY5LFUY4TMNJXHAZIFJDUPFYGLJLJONZXKZNFOZQWY5LFVIZDGNZSG44TCNBZGCBKI5DZOBS2K3DBMJSWZJLWMFWHKZNJGM2DCNJYGM2DCMMCUR2HS4DFUVWGCYTFNSSXMYLMOVS2UMJQGY3DSOBUHA2TTJ3UOJUWOZ3FOKTGG4TFMF2GK . You are receiving this email because you commented on the thread.

Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

pano9000 commented 2 months ago

@profnandaa fix PR is ready, kindly approve and merge :-)

pano9000 commented 2 months ago

fixed with https://github.com/validatorjs/validator.js/commit/ff56dcf5ad16abc4127528eafae559ac716863fb