-
Notifications
You must be signed in to change notification settings - Fork 204
Open
Labels
Description
Hi All,
the documentation of loopback 4 does not contain validations for createAll method at interceptors. Can anyone guide me on how do we validate for createAll method?
const validateOrder: Interceptor = async (invocationCtx, next) => {
console.log('log: before-', invocationCtx.methodName);
const order: Order = new Order();
if (invocationCtx.methodName == 'create')
Object.assign(order, invocationCtx.args[0]);
else if (invocationCtx.methodName == 'updateById')
Object.assign(order, invocationCtx.args[1]);
if (order.orderNum.length !== 6) {
throw new HttpErrors.InternalServerError('Invalid order number');
}
const result = await next();
return result;
};