Skip to content

Commit

Permalink
Validated more numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
NoobTenLuka committed Mar 18, 2020
1 parent 0ee52e5 commit dcf1b59
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/middlewares/check-phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ const checkPhone = (req: Request, res: Response, next: NextFunction) => {

if (firstTwo === "00" && firstFour !== "0049") {
return next(new HttpException(400, "Not a german number!"));
} else if (firstFour === "0049") {
firstFour = "0" + phoneNumber.substring(4, 7);
}

switch (firstFour) {
case "0137":
case "0700":
case "0900":
case "0180":
case "0190":
case "1180":
next(new HttpException(400, "Number not allowed"));
default:
next();
}
next();
} else {
next(new HttpException(400, "No phone number provided"));
}
Expand Down

0 comments on commit dcf1b59

Please sign in to comment.