ardent
ardent copied to clipboard
[Feature Proposal] Hook after autoHydrate before Validate
I have been using ardent for a model which also uses eloquent-sluggable. Following the documentation from there, I added a beforeValidate function that builds the "slug" before the validation happens.
Now, I want to switch to use AutoHydrate, and I find that I have the following issue. The beforeValidate hook happens before the hydration because hydration is part of the validate call. That means that when I try to run sluggify() in the beforeValidate hook, the data isn't there yet!
I would like to propose that the beforeValidate hook be moved to after hydration occurs, in order to ensure that the data is present. Additionally, I propose the addition of beforeHydrate and afterHydrate hooks to allow explicit manipulation before and after the hydration step.
These changes would mean that events occur in the following order when validate() is called:
beforeHydrate- Hydration
afterHydratebeforeValidate- Validation
afterValidate
I can submit a pull request with implementation of this if you'd like.
+1 I have found the same issue too.