yiisoft / validator

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

Remove or improve `RulesDumper` #635

Closed arogachev closed 7 months ago

arogachev commented 7 months ago

Motivation:

  1. There are no use cases other than frontend.
  2. The structure needs to be adapted to the chosen frontend library anyway.
arogachev commented 7 months ago

Related - #634. Suggested by @vjik.

@vjik also suggested adding abstract class with traversal for all rules and abstract method for serializing iterated rule.

xepozz commented 7 months ago

There are no use cases other than frontend. The structure needs to be adapted to the chosen frontend library anyway.

  1. Frontend is main goal for that class
  2. Each frontend library can create an adapter to convert yii3 rules to theirs format

Btw it's used in yii-dev-panel

vjik commented 7 months ago

We can give the user both ways.

1) Create AbstractRulesDumper that iterate rules and contain abstract method dumpRule(RuleInterface $rule). This will be easy way to create own dumper. This way for backend adpaters.

2) Keep RulesDumper, that will work the same way as now. This way for frontend adapters.

samdark commented 7 months ago

I think it has its use case and it's good as is. I'd leave it alone.

arogachev commented 7 months ago

We discussed it and decided to fix only #634 for now.