Closed Insolita closed 4 years ago
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.
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)
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.
it makes sense to disentangle ActiveRecord from Model. It shortens the inheritance tree and separates responsibilities
Out of scope of this package.
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