Skip to content

Commit

Permalink
Sync Validation Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mraysu committed Feb 15, 2024
1 parent 2ca3c26 commit 91eef56
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions backend/src/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { NextFunction, Request, Response } from "express";
import { validationResult } from "express-validator";
import admin from "firebase-admin";

import { ValidationError } from "../errors/validation";
import UserModel from "../models/user";
import { firebaseAuth } from "../util/firebase";
import validationErrorParser from "../util/validationErrorParser";

// Define the type for req.body
type CreateUserRequestBody = {
Expand All @@ -22,8 +22,9 @@ export const createUser = async (
try {
// Check for validation errors
const errors = validationResult(req);

validationErrorParser(errors);
if (!errors.isEmpty()) {
throw ValidationError.USER_CREATION_UNSUCCESSFUL;
}

const { name, accountType, email, password } = req.body;

Expand Down

0 comments on commit 91eef56

Please sign in to comment.