Allow use callable rules into Nested #770
Merged
Merged
Conversation
Nested Nested
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #770 +/- ##
============================================
+ Coverage 94.40% 96.18% +1.78%
- Complexity 953 1036 +83
============================================
Files 108 122 +14
Lines 3018 3276 +258
============================================
+ Hits 2849 3151 +302
+ Misses 169 125 -44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR extends the Nested rule to accept callables as validation rules and adds a corresponding test.
- Allow inline callable validators in
Nested - Update
ensureArrayHasRulesto recognize callables - Add test to cover callable rules and update changelog
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Rule/NestedTest.php | Added testUseCallableRules to verify inline callables |
| src/Rule/Nested.php | Modified ensureArrayHasRules to accept callables |
| CHANGELOG.md | Documented support for callable rules in Nested |
Comments suppressed due to low confidence (1)
tests/Rule/NestedTest.php:1514
- The
testUseCallableRulesmethod is missing a closing}before the next test. Add the closing brace after the assertion to avoid a syntax error.
public function testWithArrayOfObjects(): void
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
vjik
requested changes
Jun 2, 2025
Reason: To avoid modifying `RawNestedRulesArray` and `NormalizedNestedRulesArray` since changes would cause Psalm errors. Fixing these errors would require changes to `PropagateOptionsHelper`, which is used by other rules like Each that expect different input types (without callable). Since the validator would eventually convert `callable` to a `Callback` rule anyway, we can do this conversion earlier. P.S. I tried using `RulesNormalizer::normalize()`, but encountered errors in some places - plain text in two cases and an incompatible array structure in another.
samdark
approved these changes
Jun 3, 2025
vjik
requested changes
Jun 4, 2025
Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
vjik
approved these changes
Jun 4, 2025
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#611