Skip to content

Rename "Lazy" validator to "Dynamic"#1656

Closed
henriquemoody wants to merge 1 commit intoRespect:mainfrom
henriquemoody:validator/dynamic
Closed

Rename "Lazy" validator to "Dynamic"#1656
henriquemoody wants to merge 1 commit intoRespect:mainfrom
henriquemoody:validator/dynamic

Conversation

@henriquemoody
Copy link
Copy Markdown
Member

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)

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
Copy link
Copy Markdown

codecov Bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.20%. Comparing base (bcc60ec) to head (66c6dd3).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 LazyDynamic and 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
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
public static function callableDynamic(): Validator
public static function callableDynamic($input): Validator

Copilot uses AI. Check for mistakes.
@alganet
Copy link
Copy Markdown
Member

alganet commented Jan 31, 2026

Can we make the renaming of Call, Callback and Lazy in a single PR? Those are all similar (in the sense that they open doors to things Validation cannot do on its own) and I think it makes sense to consider them as a group and not individually.

@henriquemoody
Copy link
Copy Markdown
Member Author

Will do!

@henriquemoody henriquemoody deleted the validator/dynamic branch January 31, 2026 01:43
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