validator
validator copied to clipboard
Allow use callable rules into `Nested`
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.
Can you use this instead?
new Nested([
'tag' => new Callback(static fn() => (new Result())->addError('Too short.')),
]);
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.