-
Notifications
You must be signed in to change notification settings - Fork 5
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
What do you think about adding another method to the model instance that actually does the validation on saving? #2
Comments
I decided to use a separate Also, I think there should be a custom Error object made for throwing exceptions. |
This is possible, but then you would probably also want to have your validations look like this:
and the corresponding error messages:
instead of the current one which returns just the called method name. That way you can throw a custom error message for each validation even if it uses the same validation method in different models. With that setup though it would reduce boilerplate to almost nothing, and just adding the |
Also, not sure if you're interested but I refactored the plugin just to be a bit cleaner, get rid of the If you want to use that, I can make a pull request with it and for the custom error and auto-validate on save stuff after I write that. |
That would be great, but please, submit the Error emission feature as a separate pull request. I'd suggest to create a new |
Ok this is working really well, I'm happy with the result. I also recommend not adding the special I'll make a couple of PRs in a minute... |
Thank you very much for all the help you provided! I highly appreciate all of your efforts towards my project. |
Rough example:
If you want to override initialize in a model then you need to do:
I'm currently using your plugin like this and it works really nicely, saves me a ton of boilerplate. Thanks!
The text was updated successfully, but these errors were encountered: