ardent icon indicating copy to clipboard operation
ardent copied to clipboard

[Feature Proposal] Hook after autoHydrate before Validate

Open kohenkatz opened this issue 11 years ago • 1 comments

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:

  1. beforeHydrate
  2. Hydration
  3. afterHydrate
  4. beforeValidate
  5. Validation
  6. afterValidate

I can submit a pull request with implementation of this if you'd like.

kohenkatz avatar Jul 01 '14 20:07 kohenkatz

+1 I have found the same issue too.

hawle avatar Aug 08 '14 17:08 hawle