yiisoft / yiisoft/validator

Can't dump rules under Nested rule

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

Nobody has claimed this yet.

status:ready for adoption type:bug
Dominant language
PHP
Stars
167
Forks
47
Avg merge
1d 19h
Merged PRs (30d)
3

Description

class Profile
{
    #[Nested]
    public ?Requisites $requisites = null;
}

class Requisites
{
    #[Required]
    public string $bik;

    #[Required]
    public string $rs;
}

RulesDumper::asArray((new ObjectDataSet(new Profile()))->getRules());

Result will be:

'requisites' => [
    0 => [
        0 => 'nested'
        'noRulesWithNoObjectMessage' => [
'template' => 'Nested rule without rules can be used for objects only.'
            'parameters' => []
        ]
        'incorrectDataSetTypeMessage' => [
'template' => 'An object data set data can only have an array type.'
            'parameters' => []
        ]
        'incorrectInputMessage' => [
'template' => 'The value must be an array or an object.'
            'parameters' => []
        ]
        'noPropertyPathMessage' => [
'template' => 'Property "{path}" is not found.'
            'parameters' => []
        ]
        'requirePropertyPath' => false
        'skipOnEmpty' => false
        'skipOnError' => false
        'rules' => null
    ]
]

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 by reproducing the example with RulesDumper::asArray, ObjectDataSet, Profile, Requisites, and the Nested rule. Read the nested-rule handling in the dumper and verify that dumping the nested rules produces the expected rules structure without the error metadata shown in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.