Async validation#580
Async validation#580interlock wants to merge 3 commits intosequelize:masterfrom interlock:async-validate
Conversation
|
Is it not possible to maintain support for sync validation? Afaik you can check the length on the function you receive, so you can check if its expected a callback param. |
|
Ah, the breaking change is how the validation result is returned, missed that one :) |
|
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. Thoughts? |
|
Seems like the way to go. |
|
I'm pumped up and ready to test this. It's really sexy. Very nice work. |
|
Hi dudes, just wanted to note that I'm working on this and that I got the current result in Greetings, |
|
PR merge done. still need to merge it into the milestones/2.0.0 branch |
|
merge into the branch. thanks a lot! |
|
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. |
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
next()ornext(error_message)to operate correctly now.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.