-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
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