Skip to content

Commit

Permalink
added a email validition
Browse files Browse the repository at this point in the history
  • Loading branch information
alijafri691 committed Sep 16, 2024
1 parent dedb696 commit 6ac9465
Show file tree
Hide file tree
Showing 2 changed files with 4,761 additions and 3,781 deletions.
10 changes: 10 additions & 0 deletions apps/api/server/routes/api/users/index.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export default defineEventHandler(async (event) => {
const password = user.password?.trim();
const {bio, image, demo} = user;

const gmailDomain = '@gmail.com';

if (!email) {
throw createError({
status: 422,
Expand All @@ -15,6 +17,14 @@ export default defineEventHandler(async (event) => {
});
}

if (!email.includes(gmailDomain)) {
throw createError({
status: 422,
statusMessage: 'Unprocessable Content',
data: { errors: { email: ["must be a Gmail address"] } }
});
}

if (!username) {
throw createError({
status: 422,
Expand Down
Loading

0 comments on commit 6ac9465

Please sign in to comment.