Skip to content

Commit

Permalink
Add minimum length check for username in UserServiceUsernameTaken fun…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
jamalsoueidan committed Jul 4, 2024
1 parent 3b05a86 commit 327d5c7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/functions/user/services/user/username-taken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type UserServiceUsernameTakenProps = Required<Pick<User, "username">>;
export const UserServiceUsernameTaken = async ({
username,
}: UserServiceUsernameTakenProps) => {
if (username.length < 4) return { usernameTaken: true };
const usernameTaken = await UserModel.findOne({ username }).lean();
return { usernameTaken: !!usernameTaken };
};

0 comments on commit 327d5c7

Please sign in to comment.