Closed Auramel closed 4 years ago
@viktorprogger overall, this looks to be heading in the good direction, but without more visible use cases to see, I tend to agree with what @rob006 said.
Yii 3 brings DI closer to the developer, and some will want to use it even if they are not experts and do not fully grasp the consequences of their acts.
In real life, if I need to change unique
validation to work in a certain way, I would explicitly use my validator in my code, where I need it.
Allowing to replace a validator through configuration may have a lot of unexpected consequences (i.e., core depend on unique
validation to work in a certain way, I change it to another way because of my app requirements => trouble).
IMHO if somebody uses DI he understands why does he use it.
IMO it is exactly opposite - people does not understand how DI works and what are the consequences of it. Even in your implementation there is fundamental flaw which ruins 2 main goals of DI - implicit dependencies and lack of global state (Factory
will crate dependencies from nothing using some global static container).
Also note that if you want, nobody will forbid you to use DI for creating rules - you can still do this in rules()
directly. It will work the same, except that it will be explicit and framework will not promote such approach.
my point of view.
should focus on the yii3
base build.
This will allow for faster release.
I have been trying to run the demo for a year and now I can't run it.
Should I use 2.X for new projects? Refactored above after the release of 3.0
@kids-return let's keep this conversation about the new rules implementation please. And yes, you should use 2.x for new projects, as we're all doing currently, I'd hate to see 3.x rushed just for the sake of being published.
Also note that if you want, nobody will forbid you to use DI for creating rules - you can still do this in
rules()
directly. It will work the same, except that it will be explicit and framework will not promote such approach.
This is a good argument. I don't know why didn't I think about it before. I'm going to change this, but I can't give any dates, because I've changed my employer this week, and I have to join the work ASAP.
No worries. What you did is a great starting point anyway.
This one is now implemented.
Hello! So, I offer to change syntax in \yii\base\Model::rules()
For example, now we have
I offer try to code something else, for example:
I like https://github.com/Respect/Validation approach. What do you think? UPD: I don't know why tabs and spaces are not working... UPD2: Someone fixed it. Thank you 👍
Russian: хотелось бы писать правила, как в ссылке выше. :) UPD: Хз почему все переносы и табы слетели... Писал в Notepad++...
UPD2: Кто-то пофиксил. Спасибо 👍