yiisoft / validator

Yii validator library
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
110 stars 36 forks source link

Extract rule name and options to separate collector #682

Open vjik opened 3 months ago

vjik commented 3 months ago

My suggestion:

1) Remove method RuleInterface::getName(). 2) Remove interface RuleWithOptionsInterface. 3) Remove RulesDumper. 4) Create new RulesConvertor that would can be configured for usage with custom rules also.

Benefits:

samdark commented 3 months ago
  1. As an author of the custom rule, what would be different for me to implement / use the rule?
  2. What if I want to ship it in a Composer package?
  3. As a rule user, what would be different for me?
vjik commented 3 months ago
  1. As an author of the custom rule, what would be different for me to implement / use the rule?

Implementation:

Usage:

  1. What if I want to ship it in a Composer package?

It can be configured via Yii Config or manually.

  1. As a rule user, what would be different for me?

See 1.

samdark commented 3 months ago

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.

vjik commented 3 months ago

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.