Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.1|3.0] proposal ActiveRecords class without validation first #14

Closed
Insolita opened this issue Nov 25, 2017 · 5 comments
Closed

[2.1|3.0] proposal ActiveRecords class without validation first #14

Insolita opened this issue Nov 25, 2017 · 5 comments

Comments

@Insolita
Copy link

In some simple cases internal model validation not bad, but in more complex cases when validation is in separate classes and save/update operations wrapped into services/repositories, validation-scenario functional seems like overhead and thereare reasons for prohibit direct usage of $model->load($data) && $model->validate() and internal rules configuration;

So my proposal - extract validation feature in trait and add something like SelfValidationInterface, instead of BaseActiveRecord extends Model

@samdark
Copy link
Member

samdark commented Nov 25, 2017

In general entity should validate data that is set into it. If you don't need it for some reason, you can pass false to save(). But maybe I don't get what the issue is... worth elaborating.

@Insolita
Copy link
Author

There are not technical issue, it's more about architecture. A lot of controversy about where to make the validation. I think this should be discussed. (I`ve troubles with access to facebook discussion)

@samdark
Copy link
Member

samdark commented Nov 25, 2017

Usually entity validates itself and there could be more validation added in the layers wrapping it. These layers have an ability to disable entity validation. It all depends on the use case.

@dynasource
Copy link
Member

it makes sense to disentangle ActiveRecord from Model. It shortens the inheritance tree and separates responsibilities

@samdark samdark transferred this issue from yiisoft/yii2 May 14, 2019
@samdark
Copy link
Member

samdark commented Dec 26, 2019

Out of scope of this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants