mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-23 23:52:05 -05:00
Add explicit error code to APIError
Signed-off-by: GautamBytes <manchandanigautam@gmail.com>
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user