Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to apply the same validating ruleset to multiple attributes #724

Open
karolls opened this issue Jun 23, 2024 · 2 comments
Open

Allow to apply the same validating ruleset to multiple attributes #724

karolls opened this issue Jun 23, 2024 · 2 comments
Labels
type:feature New feature

Comments

@karolls
Copy link

karolls commented Jun 23, 2024

What steps will reproduce the problem?

It is impossible to apply the same set of rules to multiple attributes of an object or an array.

What is the expected result?

Would be really useful to be able to apply same set of rules to multiple attributes at the same time (like it was in Yii2). Coulb be done with something like:

$rules = [
    new Some(['email', 'emailConfirmation'], [
        new Required(),
        new Email()
    ]),
];

or

$rules = [
    new Some(['field1', 'field2', 'field3', ...], new Required()),
];

What do you get instead?

Now I need to duplicate code like this:

$rules = [
    'field1' => new Required(),
    'field2' => new Required(),
    'field3' => new Required(),
    ...
];

Additional info

Q A
Version 1.4.1
PHP version 8.3
Operating system Linux
@vjik vjik added the type:feature New feature label Jun 24, 2024
@vjik
Copy link
Member

vjik commented Jun 24, 2024

We need to come up with a good name for the rule.

@samdark
Copy link
Member

samdark commented Jun 30, 2024

ApplyTo, Fields, For.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature
Projects
None yet
Development

No branches or pull requests

3 participants