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

[10.x] Added parameters to timezone validation rule #47171

Merged
merged 5 commits into from
May 23, 2023
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
9 changes: 7 additions & 2 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Brick\Math\Exception\MathException as BrickMathException;
use DateTime;
use DateTimeInterface;
use DateTimeZone;
use Egulias\EmailValidator\EmailValidator;
use Egulias\EmailValidator\Validation\DNSCheckValidation;
use Egulias\EmailValidator\Validation\Extra\SpoofCheckValidation;
Expand Down Expand Up @@ -2285,11 +2286,15 @@ public function validateString($attribute, $value)
*
* @param string $attribute
* @param mixed $value
* @param array<string, null|string> $parameters
* @return bool
*/
public function validateTimezone($attribute, $value)
public function validateTimezone($attribute, $value, $parameters = [])
{
return in_array($value, timezone_identifiers_list(), true);
return in_array($value, timezone_identifiers_list(
constant(DateTimeZone::class.'::'.Str::upper($parameters[0] ?? 'ALL')),
isset($parameters[1]) ? Str::upper($parameters[1]) : null,
), true);
}

/**
Expand Down
Loading