Hi colleagues,
usually if multiple errors are expected we throw it like this:
srv.on('CREATE', 'myEntity' req => {
if (true) {
req.error(400, 'nope 1');
req.error(400, 'nope 2');
return;
}
})
Sometimes though we want to clean up our handler so that it turns into kind of this:
validateBeforeCreateMyEntity(req) {
if (true) {
req.error(400, 'nope 1');
req.error(400, 'nope 2');
// here I want to reject the request with multiple errors which means I probably can't use req.reject as it returns only a single error
}
}
srv.before('CREATE', 'myEntity' req => {
validateBeforeCreateMyEntity(req);
// assume we have 50 more lines here
})
Is there currently any way to do it?
p.s currently in CAP documentation it's just
if (req.errors) //> get out somehow...
Thank you.