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

[11.x] Refactor validation rule parsing for improved readability #54417

Closed
wants to merge 2 commits into from

Conversation

michaelnabil230
Copy link
Contributor

@michaelnabil230 michaelnabil230 commented Jan 30, 2025

This PR enhances the explodeExplicitRule to support rules as both strings and arrays. In the future, rules can be used as strings with | for validation, eliminating the need for instanceof checks for specific classes like the Date rule.

@michaelnabil230 michaelnabil230 changed the title [11.x] Refactor validation rule parsing for improved readability and perform… [11.x] Refactor validation rule parsing for improved readability Jan 30, 2025
src/Illuminate/Validation/ValidationRuleParser.php Outdated Show resolved Hide resolved
src/Illuminate/Validation/ValidationRuleParser.php Outdated Show resolved Hide resolved
return array_map(
[$this, 'prepareRule'],
$rule,
array_fill((int) array_key_first($rule), count($rule), $attribute)
Copy link
Contributor

Choose a reason for hiding this comment

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

The (int) cast doesn't make sense. You probably expect the key to be of type int anyway, but if it for some reason is not, casting a potentially non-empty string to int won't be very helpful, would it?

@michaelnabil230 michaelnabil230 deleted the improve-rule branch January 30, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants