Skip to content
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

DateTime validation fails on valid ISO-8601 timestamp #1439

Closed
manuelmaurer opened this issue Dec 6, 2023 · 1 comment
Closed

DateTime validation fails on valid ISO-8601 timestamp #1439

manuelmaurer opened this issue Dec 6, 2023 · 1 comment

Comments

@manuelmaurer
Copy link

I'm trying to validate this json input:
{ "ts": "2019-02-08T09:04:05.317Z" }
using this rule:
v::key('ts', v::nullable(v::dateTime('c')))

Which fails, because it does not like the fractional second part (which PHP's DateTime does support). The source seems to be this conversion into a fixed format for the date_parse_from_format function call: https://github.com/Respect/Validation/blob/master/library/Helpers/CanValidateDateTime.php#L33

As the fractional part seems to be quite complicated in the standard, I'm not sure if this is an easy thing to fix. I'll try to play around a bit when I get the time.

@henriquemoody
Copy link
Member

I'm sorry for my belated response!

Your date should work fine as long as you use the format that matches your date. In your case, that would be Y-m-d\TH:i:s.vp.

Here for more information: #1442 (comment)

If I misunderstood your request, feel free to reopen the issue. I'm here to help! 🐼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants