Open vjik opened 1 year ago
What the reason to have two the same interfaces but with different methods' names?
RuleInterface:
validate($value, $rule, $context): Result
CallableRuleInterface:
__invoke($value, $rule, $context): Result
CallableRuleInterface
is not rule, it's callable only.
What do you mean by it's callable only
?
What do you mean by
it's callable only
?
It's not rule. Object does not implement RuleInterface
.
Callable rule class may look like this:
For simple custom rules is good solution, but there is one problem. It is not possible usage as attribute.
We can add attribute
Attribute
:It's not enough, because validator parse attributes that implement
RuleInterface
only.Suggest add new interface
CallableRuleAttributeInterface
and parse implementing its attributes in addition toRuleInterface
.