validator
validator copied to clipboard
Extract rule name and options to separate collector
My suggestion:
- Remove method
RuleInterface::getName(). - Remove interface
RuleWithOptionsInterface. - Remove
RulesDumper. - Create new
RulesConvertorthat would can be configured for usage with custom rules also.
Benefits:
- more clear rule classes
- allows move all default values to rule handlers, that allow override default values globally.
- As an author of the custom rule, what would be different for me to implement / use the rule?
- What if I want to ship it in a Composer package?
- As a rule user, what would be different for me?
- As an author of the custom rule, what would be different for me to implement / use the rule?
Implementation:
- method
RuleInterface::getName()need to implement only when user used convertation rules to array - if options needed, then yet another class for convert rule to array will be required (also user can implement new interface in rule).
Usage:
- add ability to change converatation to array for any rule.
- What if I want to ship it in a Composer package?
It can be configured via Yii Config or manually.
- As a rule user, what would be different for me?
See 1.
I like the ability to configure it, but I don't think we need to separate this information, since it logically belongs to rule itself.
In some cases need ability to configure converter rule to array. For example date format in date rule. In this case need to use separate converter.