Rename "Lazy" validator to "Dynamic"#1656
Conversation
The name "Dynamic" better conveys the validator's purpose: dynamically creating a validator at runtime based on the input value. "Lazy" was misleading as it suggested simple deferred evaluation rather than input-dependent validator construction. Also renamed the constructor argument from `$validatorCreator` to `$factory` for improved expressiveness. Assisted-by: Claude Code (Opus 4.5)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1656 +/- ##
=========================================
Coverage 99.20% 99.20%
Complexity 917 917
=========================================
Files 191 191
Lines 2146 2146
=========================================
Hits 2129 2129
Misses 17 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Renames the Lazy validator to Dynamic across the codebase to better reflect its purpose (creating validators at runtime based on input), including updates to public-facing docs and test suites.
Changes:
- Renamed validator class/API from
Lazy→Dynamicand updated error message text accordingly. - Updated mixin/builder method declarations (
lazy()→dynamic()and prefixed variants). - Updated unit/feature tests, smoke test provider, and documentation to use the new name.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/Validators/DynamicTest.php | Updates unit tests to reference Dynamic instead of Lazy. |
| tests/src/SmokeTestProvider.php | Updates smoke test entries/callables to use Dynamic. |
| tests/feature/Validators/DynamicTest.php | Updates feature tests to call v::dynamic() instead of v::lazy(). |
| tests/feature/Validators/CircuitTest.php | Updates circuit example usage to v::dynamic(). |
| src/Validators/Dynamic.php | Renames the validator class and constructor arg ($validatorCreator → $factory). |
| src/Mixins/UndefOrChain.php | Replaces undefOrLazy() with undefOrDynamic() declaration. |
| src/Mixins/UndefOrBuilder.php | Replaces undefOrLazy() with undefOrDynamic() declaration. |
| src/Mixins/PropertyChain.php | Replaces propertyLazy() with propertyDynamic() declaration. |
| src/Mixins/PropertyBuilder.php | Replaces propertyLazy() with propertyDynamic() declaration. |
| src/Mixins/NullOrChain.php | Replaces nullOrLazy() with nullOrDynamic() declaration. |
| src/Mixins/NullOrBuilder.php | Replaces nullOrLazy() with nullOrDynamic() declaration. |
| src/Mixins/NotChain.php | Replaces notLazy() with notDynamic() declaration. |
| src/Mixins/NotBuilder.php | Replaces notLazy() with notDynamic() declaration. |
| src/Mixins/KeyChain.php | Replaces keyLazy() with keyDynamic() declaration. |
| src/Mixins/KeyBuilder.php | Replaces keyLazy() with keyDynamic() declaration. |
| src/Mixins/Chain.php | Replaces lazy() with dynamic() declaration. |
| src/Mixins/Builder.php | Replaces lazy() with dynamic() declaration. |
| src/Mixins/AllChain.php | Replaces allLazy() with allDynamic() declaration. |
| src/Mixins/AllBuilder.php | Replaces allLazy() with allDynamic() declaration. |
| docs/validators/Dynamic.md | Renames validator docs page and updates examples to dynamic(). |
| docs/validators/Circuit.md | Updates references/examples from Lazy to Dynamic. |
| docs/validators/CallableType.md | Updates “See Also” links to include Dynamic instead of Lazy. |
| docs/validators/Call.md | Updates “See Also” links to include Dynamic instead of Lazy. |
| docs/validators.md | Updates validator index/category listings and examples to Dynamic. |
| docs/migrating-from-v2-to-v3.md | Updates migration guide references from Lazy to Dynamic. |
| docs/feature-guide.md | Updates feature guide references from Lazy to Dynamic. |
Comments suppressed due to low confidence (9)
tests/feature/Validators/DynamicTest.php:53
- The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
src/Validators/Dynamic.php:36 - Dynamic::evaluate always invokes the factory with the input argument. If a consumer passes a 0-argument callable, PHP 8+ will throw an ArgumentCountError (fatal) instead of a validation ComponentException. Consider validating the callable arity (or catching ArgumentCountError) and throwing a ComponentException with a clear message about the expected factory signature.
tests/feature/Validators/DynamicTest.php:13 - The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
tests/feature/Validators/DynamicTest.php:21 - The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
tests/feature/Validators/DynamicTest.php:37 - The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
tests/feature/Validators/DynamicTest.php:61 - The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
tests/feature/Validators/DynamicTest.php:69 - The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
tests/feature/Validators/DynamicTest.php:29 - The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
tests/feature/Validators/DynamicTest.php:45 - The factory passed to v::dynamic will be called with the input value. Using a 0-argument closure here will raise an ArgumentCountError on PHP 8+. Make the closure accept the input parameter (even if unused), e.g. fn($input) => ...
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| public static function callableLazy(): Validator | ||
| public static function callableDynamic(): Validator |
There was a problem hiding this comment.
This factory method is passed to vs\Dynamic and will be invoked with the input value. As declared, callableDynamic() takes no parameters, which will raise an ArgumentCountError on PHP 8+. Update callableDynamic to accept the input parameter (even if unused) or adjust Dynamic to support 0-arg factories.
| public static function callableDynamic(): Validator | |
| public static function callableDynamic($input): Validator |
|
Can we make the renaming of |
|
Will do! |
The name "Dynamic" better conveys the validator's purpose: dynamically creating a validator at runtime based on the input value. "Lazy" was misleading as it suggested simple deferred evaluation rather than input-dependent validator construction.
Also renamed the constructor argument from
$validatorCreatorto$factoryfor improved expressiveness.Assisted-by: Claude Code (Opus 4.5)