loopback
loopback copied to clipboard
Model hook "before save" is executed before validateAsync is finished
I have define validateAsync methods for my model and found that Model hook "before save" is executed even though my model validation (async) return false. In my opinion, it should be an issue, right?
hi @mackwan84, would you be able to provide steps to reproduce your issue? Report Bug
Because validateAsync runs asynchronously, I believe you would have to validate the model before the operational hook methods if you need to use validateAsync
Model.beforeSave = function(cb, modelInstance){
modelInstance.isValid( function( isValidResult ){
cb();
}
}
Cleaning up stale issues, please reopen if this issue still persist, thanks!