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 use callable rules into Nested #611

Open
vjik opened this issue Jun 22, 2023 · 2 comments
Open

Allow use callable rules into Nested #611

vjik opened this issue Jun 22, 2023 · 2 comments
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement

Comments

@vjik
Copy link
Member

vjik commented Jun 22, 2023

For Example:

new Nested([
    'tag' => static fn() => (new Result())->addError('Too short.'),
]);

Now it's throw exception:

InvalidArgumentException: Every rule must be an instance of Yiisoft\Validator\RuleInterface, Closure given.
@BoShurik
Copy link

Can you use this instead?

new Nested([
    'tag' => new Callback(static fn() => (new Result())->addError('Too short.')),
]);

@vjik
Copy link
Member Author

vjik commented Jun 22, 2023

Can you use this instead?

new Nested([
    'tag' => new Callback(static fn() => (new Result())->addError('Too short.')),
]);

Yes, it's work. But my suggestion is more simpler and consistently with rules syntax that pass to Validator.

@samdark samdark added the type:enhancement Enhancement label Jun 26, 2023
@arogachev arogachev added the status:ready for adoption Feel free to implement this issue. label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

4 participants