8000 Update ValidatesAttributes.php by Norgul · Pull Request #36953 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Update ValidatesAttributes.php #36953

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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Next Next commit
Update ValidatesAttributes.php
  • Loading branch information
Norgul authored Apr 12, 2021
commit 88b0e582ea2582b9624ecd0628a467c54d5e015a
16 changes: 15 additions & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
C137 Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ public function parseDependentRuleParameters($parameters)

$values = array_slice($parameters, 1);

if (is_bool($other)) {
if ($this->shouldConvert($parameters[0], $other) || is_bool($other)) {
$values = $this->convertValuesToBoolean($values);
} elseif (is_null($other)) {
$values = $this->convertValuesToNull($values);
Expand All @@ -1563,6 +1563,20 @@ public function parseDependentRuleParameters($parameters)
return [$values, $other];
}

/**
* Check if parameter should be converted to boolean
*
* @param $parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid syntax

* @param mixed $other
* @return bool
*/
protected function shouldConvert($parameter, $other)
{
$rules = Arr::get($this->rules, $parameter, []);

return in_array('boolean', $rules);
}

/**
* Convert the given values to boolean if they are string "true" / "false".
*
Expand Down
0