[12.x] Refine type hinting for condition rules#56420
Conversation
RequiredIf rule|
This is a breaking change for me. Originally In my case I was applying the rule if a route param was present. Sure, I can cast it to boolean pretty simply but a breaking change in a patch version is not ideal, in a PR focusing on type hints nonetheless. Rule::requiredIf($this->route('label'))I agree that the original A better approach might be to accept any value, string or not, this too would be a breaking change, however only for those expecting an If the strictness is to stay, there is no reason why native types can't be used. public function __construct(Closure|bool|null $condition)
{
$this->condition = $condition;
}My vote is to drop the strictness and allow any truthy/falsy value. Happy to PR something to fix this breaking change pending your opinion @taylorotwell |
Refine type hinting for condition rules