yiisoft / validator

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

Move out `getName()` from `RuleInterface` #634

Closed arogachev closed 7 months ago

arogachev commented 7 months ago

Case - REST API without usage on the frontend, serialization of rules are not required.

vjik commented 7 months ago

What use as name for rules without name?

arogachev commented 7 months ago

If there is an attempt to serialize the rule without name, an exception can be thrown for example.

BoShurik commented 7 months ago

We may use FQCN as a name

vjik commented 7 months ago

After discussion, we came to the following decision.

  1. Move getName() from RuleInterface to RuleWithOptionsInterface.
  2. Built-in rules must returns own FQCN as rule name.
  3. RulesDumper for rules that not implemented RuleWithOptionsInterface, use rule FQCN as name and empty array as options.
  4. Rename RuleWithOptionsInterface to more correct name.
arogachev commented 7 months ago

Working on it.

arogachev commented 7 months ago

@BoShurik Thanks for your suggestion.