loopbackio / loopbackio/loopback4-example-shopping

Email validation for createAll method

Open
#1,267 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs clarification
Dominant language
TypeScript
Stars
365
Forks
195
PR merge metrics
No merged PRs in 30d

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;
};

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the interceptor example in the issue and the LoopBack 4 documentation for create, updateById, and createAll. Determine how createAll arguments are exposed to an interceptor and document the validation approach and expected behavior. Done means the documentation clearly explains how to validate email values for createAll.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.