Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions system/Validation/FormatRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ public function valid_url_strict(?string $str = null, ?string $validSchemes = nu
*/
public function valid_date(?string $str = null, ?string $format = null): bool
{
if ($str === null) {
return false;
}

if (empty($format)) {
return strtotime($str) !== false;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/system/Validation/FormatRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,11 @@ public function testValidDate(?string $str, ?string $format, bool $expected): vo
public function validDateProvider(): Generator
{
yield from [
[
null,
'Y-m-d',
false,
],
[
'Sun',
'D',
Expand Down