-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isDate returns false for all strings #2389
Comments
This issue is interesting. I want to work on it. |
Thanks! I also made this minimal example for testing purposes in HTML, to
be helpful. I couldn't figure out a way to upload this on github without
creating a repo, so I'm attaching it here.
ValidatorJs is great! Keep up the good work & thank you again for being so
responsive.
-Brighid
…On Tue, Apr 16, 2024 at 5:53 AM Landry Bitege ***@***.***> wrote:
The result is interesting. I want to work on it.
—
Reply to this email directly, view it on GitHub
<#2389 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BGEAT24FSYE67PYZNHFVUL3Y5UNODAVCNFSM6AAAAABGGMSCGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJZGAZDGMBSGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hello sir, for this issue I think you are wrong in your code. because I
just simulated validatorjs with the same example as you but it really works
in my environment.
But unfortunately I can't see the example you sent me. If there's any way
you can send it back to me.
Le mar. 16 avr. 2024 à 21:50, ElimuTek ***@***.***> a écrit :
… Thanks! I also made this minimal example for testing purposes in HTML, to
be helpful. I couldn't figure out a way to upload this on github without
creating a repo, so I'm attaching it here.
ValidatorJs is great! Keep up the good work & thank you again for being so
responsive.
-Brighid
On Tue, Apr 16, 2024 at 5:53 AM Landry Bitege ***@***.***>
wrote:
> The result is interesting. I want to work on it.
>
> —
> Reply to this email directly, view it on GitHub
> <
#2389 (comment)>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/BGEAT24FSYE67PYZNHFVUL3Y5UNODAVCNFSM6AAAAABGGMSCGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJZGAZDGMBSGQ>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#2389 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BBT4Q6G7KNGOM4YK6KALX63Y5V6JZAVCNFSM6AAAAABGGMSCGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJZHAYTMNZXGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
*Landry Bitege*
*Développeur Web et Mobile*
+243 973 173 176
|
I am also seeing this issue, using the latest version 13.11.0. It's a brand new install; just started using the package today. I do love how simple it is to implement. If it helps; I pulled the code directly in to my system and it ran fine, but my original code is in typescript. I am wondering if there is a transpile issue somewhere along the way. |
Hmm.. I've tried all the examples provided by @ElimuTek and everything is working as expected. I wasn't able to reproduce your issue. Could it be an issue with the way you're handling the data after submission? You can perhaps share the code. That should help in reproduction and, eventually, troubleshooting.
|
Can I have a look at the code @PAllisonVSO? |
I will try and put together a full working repository as I have time this week; work is currently super busy. Thanks for taking the time to respond! |
I just put together a test package and used version 13.12.0 and everything is working, so I tried it in the original package and it is working there as well; it must have gotten resolved. Thanks! |
Still facing the same issue. Below is the code that I have:
|
@SyedAzeemJaved from your code aboce it looks like you are using but even If I try with 13.9.0 I still get "true" for the date you provided above. in what timezone is the computer you ran the code above? just to rule out some strange edge case, that may have been fixed with #2257 |
isDate returns false for all strings
isDate is always returning false, even for correctly formatted strings.
Examples
validator.isDate('2024-01-01', { format: 'YYYY-MM-DD', delimiters: ['-'] }); // false
validator.isDate("2024/01/01"); // false
validator.isDate(new Date('2024-01-01')); // true
validator.isDate(validator.toDate("1")); // true
The only way I was able to make the result come back true was to coerce the date into native date format with validator.isDate(new Date(
${inputValue}
)) or validator.isDate(validator.toDate(inputValue)). This is not a viable workaround as the last example shows (returns valid for "1").It seems like isDate is expecting an object, but the tool is intended for string validation.
Notably other validators like isBefore and isAfter are working correctly with the same date format YYYY/MM/DD, as a string.
Additional context
Validator.js version: 13.11.0
included via cdn: <script src="https://unpkg.com/validator@latest/validator.min.js"></script>
Node.js version: 18.16.0
OS platform: windows
The text was updated successfully, but these errors were encountered: