Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new Trimmed validator that ensures string inputs do not start or end with specific values, defaulting to a comprehensive list of Unicode whitespace and zero-width characters. It also extends the StartsWith and EndsWith validators to accept multiple values, enabling more flexible validation patterns.
Changes:
- Added new
Trimmedvalidator with support for default Unicode invisible characters and custom trim values - Modified
StartsWithandEndsWithvalidators to accept multiple values via variadic parameters - Updated all mixin interfaces (Builder, Chain, NotBuilder, NotChain, etc.) to reflect new method signatures
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Validators/Trimmed.php | New validator that composes StringType, StartsWith, EndsWith, AnyOf, and Not to validate trimmed strings |
| src/Validators/StartsWith.php | Enhanced to support multiple start values with OR logic and new template for multiple values |
| src/Validators/EndsWith.php | Enhanced to support multiple end values with OR logic and new template for multiple values |
| tests/unit/Validators/TrimmedTest.php | Unit tests covering default Unicode characters, custom trim values, and edge cases |
| tests/feature/Validators/TrimmedTest.php | Feature tests for default/inverted templates and custom alternatives |
| tests/unit/Validators/StartsWithTest.php | Additional test cases for multiple value support |
| tests/unit/Validators/EndsWithTest.php | Additional test cases for multiple value support |
| tests/feature/Validators/StartsWithTest.php | Feature tests for multiple value error messages |
| tests/feature/Validators/EndsWithTest.php | Feature tests for multiple value error messages |
| tests/src/SmokeTestProvider.php | Added smoke test entry for Trimmed validator |
| src/Mixins/*.php | Updated method signatures for startsWith, endsWith, and added trimmed methods across all mixin files |
| docs/validators/Trimmed.md | New documentation explaining Trimmed validator usage, templates, and examples |
| docs/validators/StartsWith.md | Updated documentation for multiple values support with examples and new template |
| docs/validators/EndsWith.md | Updated documentation for multiple values support with examples and new template |
| docs/validators.md | Updated validator index to include Trimmed and updated descriptions for StartsWith |
Comments suppressed due to low confidence (1)
src/Validators/EndsWith.php:27
- Missing import for
is_stringfunction. This should be added to the use function statements to match the pattern in StartsWith and to support the necessary type safety check on line 75.
use function count;
use function end;
use function is_array;
use function mb_strlen;
use function mb_strrpos;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This commit introduces the `Trimmed` validator that ensures a string cannot start or end with a list of specific values. The default values used are a selected list of Unicode invisible characters. To support this change, the StartsWith and EndsWith validators were modified so they can also support multiple values to check for. While StartsWith and EndsWith are more generic, and also perform start-of-array and end-of-array kinds of checks, Trimmed is more focused on string inputs, which tailors to a more specific use case.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.0 #1702 +/- ##
=========================================
Coverage 99.47% 99.48%
- Complexity 979 994 +15
=========================================
Files 193 194 +1
Lines 2294 2333 +39
=========================================
+ Hits 2282 2321 +39
Misses 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This commit introduces the
Trimmedvalidator that ensures a string cannot start or end with a list of specific values.The default values used are a selected list of Unicode invisible characters.
To support this change, the StartsWith and EndsWith validators were modified so they can also support multiple values to check for.
While StartsWith and EndsWith are more generic, and also perform start-of-array and end-of-array kinds of checks, Trimmed is more focused on string inputs, which tailors to a more specific use case.