Add explicit error code to APIError

Signed-off-by: GautamBytes <manchandanigautam@gmail.com>
This commit is contained in:
GautamBytes
2025-11-15 16:09:19 +00:00
parent 710281fca8
commit d6788b8d7b

View File

@@ -253,6 +253,7 @@ export const username = (options?: UsernameOptions | undefined) => {
username,
});
throw new APIError("UNPROCESSABLE_ENTITY", {
code: "USERNAME_TOO_SHORT",
message: ERROR_CODES.USERNAME_TOO_SHORT,
});
}
@@ -429,6 +430,7 @@ export const username = (options?: UsernameOptions | undefined) => {
if (username.length < minUsernameLength) {
throw new APIError("UNPROCESSABLE_ENTITY", {
code: "USERNAME_TOO_SHORT",
message: ERROR_CODES.USERNAME_TOO_SHORT,
});
}
@@ -495,6 +497,7 @@ export const username = (options?: UsernameOptions | undefined) => {
const maxUsernameLength = options?.maxUsernameLength || 30;
if (username.length < minUsernameLength) {
throw new APIError("BAD_REQUEST", {
code: "USERNAME_TOO_SHORT",
message: ERROR_CODES.USERNAME_TOO_SHORT,
});
}