You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$v = newDateValidator([
'type' => 'datetime',
'format' => 'php:c'
]);
Case1:
$v->validate('2004-02-12T15:19:21+00:00', $err); <---- this example is from php.net
VarDumper::dump($err); <--- 'The format of the input value is invalid.'Case2:
$v->validate('2004-02-12T15:19:21+0000', $err);
VarDumper::dump($err); <--- 'The format of the input value is invalid.'
---
$v2 = newDateValidator([
'type' => 'datetime',
'format' => 'php:'.DATE_ATOM
]);
Case3:
$v2->validate('2004-02-12T15:19:21+0000', $err);
VarDumper::dump($err); <--- nullCase4:
$v2->validate('2004-02-12T15:19:21+00:00', $err);
VarDumper::dump($err); <--- null
What is the expected result?
For case 1 -> Validation should pass
What do you get instead?
For case 1 -> Validation fails
Additional info
Q
A
Yii version
2.0.47
PHP version
Operating system
The text was updated successfully, but these errors were encountered:
This is a PHP issue, I can see that both c and r are not working. I'm not sure if it should be reported though, PHP says for example that their DateTimeInterface::ISO8601 should not be used since it's not really ISO8601 and to use ISO8601_EXPANDED or ATOM instead. Maybe this is the case as well? c looks like a weird mix between ISO8601 and ISO8601_EXPANDED.
We could throw an InvalidConfigException on init when php:c or php:r is used as a format with the suggestion to use proper formats.
We could throw an InvalidConfigException on init when php:c or php:r is used as a format with the suggestion to use proper formats.
I disagree. Throwing error and preventing further execution is not the best option in my humble opinion. I suggest to log a warning/notice with details of the issue and suggesting work-arounds
I observed a strange behaviour of \yii\validators\DateValidator.
From PHP docs
What steps will reproduce the problem?
What is the expected result?
For case 1 -> Validation should pass
What do you get instead?
For case 1 -> Validation fails
Additional info
The text was updated successfully, but these errors were encountered: