Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email validation for createAll method #1267

Open
smithasmi95 opened this issue Jul 29, 2021 · 1 comment
Open

Email validation for createAll method #1267

smithasmi95 opened this issue Jul 29, 2021 · 1 comment

Comments

@smithasmi95
Copy link

smithasmi95 commented Jul 29, 2021

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;

};

@mrmodise
Copy link
Contributor

mrmodise commented Sep 29, 2021

@smithasmi95 sorry I don't think I follow as your code snippet does not illustrate any createAll logic. Some tips if the question is not related to this repo I would suggest you ask it on Slack or via LoopBack monorepo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants