Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Async validation #580
This is an updated pull request for issue #275.
This PR actually breaks existing implementations, because we had to use promises as the return result. As a result, I suggest we create a 2.0 branch that implements this and other changes which may regress for people.
Docs would need to be updated for this update (if accepted in 2.0 branch, will provide this update).
Custom validators need to call
model->validate() returns a promise, use like so
Once accepted, it would be fairly easy to adjust a models save to call validate before save as well. There are a few PR's for that as well.
Ya, I'm not the original implementor of this solution; but, it looks like to get async support you can no longer trust the return result to return. Of course, perhaps we could wrap that in a function in the Chainer to fake it? That still leaves the actual
Talking to sdepold_ on skype the other day and we both thought it would be a good idea to start a future branch for 2.0-wip and merge this in there. We could manage the 1.x series as far as it can go without major refactor and save big breaks for 2.0.
is it a requirement to decouple validation from saving?
From what i gather, the goal here was to make validators asynchronous...
Can't validation be piped back to saving so it doesn't break anything?
A separate method
Can we afford to rethink this?
@thanpolas parts of that flow have been added in 1.7.0 but not upstreamed. Only exception to that would be it has no toggle for skipping validation.
It appears there has been a fairly large refactor of validation in the 1.7 series in general, so upstreaming those changes may not work. We are actually phasing out Sequelizer in our project in favour of another ORM right now, so not sure if we can dedicate time to work out an upstream merge for those validation updates.