Skip to content

Got misunderstanding configuring rules over attributes #243

@xepozz

Description

@xepozz

I've found a few problems:

  1. All rules don't have REPEATABLE flag.
  2. Each, Nested rules (but suddenly not Group, Composite) don't work at all without additional attributes.

We have great example with composition of attributes, but configuring an inheritance have to be different.

How it's configuring now.

How it should be configured:

final class ChartsData
{
    #[Each(
        rules: [
            new HasMany(Chart::class),
        ],
        incorrectInputMessage: 'Custom message 1.',
        message: 'Custom message 2.'
    )]
    private array $charts;
}

But HasMany and HasOne aren't Rules, so they can't be passed into rules. We need to make another rule something like "as from $classname". The implementation and name are up to developer.

I'll make a pr with tests those should pass

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions