fix(rules): datetime class accept invalid dates
This commit is contained in:
parent
2306622b81
commit
5b43cb6f5a
@ -20,5 +20,10 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
if (\DateTimeImmutable::createFromFormat("Y-m-d", $value) === false) {
|
||||
$fail('validation.format.date_ymd');
|
||||
}
|
||||
// DateTime accept dates such as 2021-31-55
|
||||
$errors = \DateTimeImmutable::getLastErrors();
|
||||
if (!empty($errors['warning_count'])) {
|
||||
$fail('validation.date_ymdhi');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,10 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
if (\DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $value . ":00") === false) {
|
||||
$fail('validation.date_ymdhi');
|
||||
}
|
||||
// DateTime accept dates such as 2021-31-55
|
||||
$errors = \DateTimeImmutable::getLastErrors();
|
||||
if (!empty($errors['warning_count'])) {
|
||||
$fail('validation.date_ymdhi');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,10 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
if (\DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $value) === false) {
|
||||
$fail('validation.date_ymdhis');
|
||||
}
|
||||
// DateTime accept dates such as 2021-31-55
|
||||
$errors = \DateTimeImmutable::getLastErrors();
|
||||
if (!empty($errors['warning_count'])) {
|
||||
$fail('validation.date_ymdhi');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user