Add event to make model validation extendable#139
Conversation
|
|
@bennothommo any idea what the error in code analysis is about? |
|
The static code analysis test has been a bit flaky recently. Feel free to ignore it for now. |
|
@mjauvin is it possible to just dynamically extend a model and add validation rules? Model::extend(function ($model) {
$model->rules['newField'] = 'required';
// etc...
}); |
|
@bennothommo not sure I understand the relevance here |
|
@mjauvin I'm asking if there's any need to create a new event when a model extension can do it already. If the Translatable behavior needs to implement validation on the fly, you can create a Rule class which handles the validation needed for the translation, and simply add that Rule class through the model extension. |
|
@bennothommo but it doesn't need to create new rules. just apply the existing rules to the translations. |
|
Any objection on merging this? |
|
@bennothommo any thoughts on this? |
|
Nope, no additional thoughts. If it works, it's all good by me. |
|
This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days. |
|
Can this be merged, it would allow me to continue work on the associated PR in Translate plugin (wintercms/wn-translate-plugin#52) ? |
Needed to add Validation to translatable Model attributes in Winter.Translate plugin.
Used by wintercms/wn-translate-plugin#52