yiisoft / yiisoft/validator

Generators are not used to the fullest in `Nested` rule

Open
#433 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:enhancement
Dominant language
PHP
Stars
167
Forks
47
Avg merge
1d 19h
Merged PRs (30d)
3

Description

Regardless of the passed rules' type it will always converted to array after this internal check:

https://github.com/yiisoft/validator/blob/d0765827ad0afa0304379ccbb32e7bb5d976b5d1/src/Rule/Nested.php#L175

https://github.com/yiisoft/validator/blob/d0765827ad0afa0304379ccbb32e7bb5d976b5d1/src/Rule/Nested.php#L192

Need to adjust ensureArrayHasRules() behavior. Or maybe go even further and validate it on the fly in the handler?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Rule/Nested.php at the referenced lines around ensureArrayHasRules() and trace how passed rules are converted and validated. Clarify whether generators should remain lazy or be validated in the handler, then verify that the chosen behavior no longer eagerly converts every rule type to an array.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.