-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add message, username, and password max lengths
- Loading branch information
1 parent
058cc0a
commit de68141
Showing
3 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const LIMITS = { | ||
USERNAME_MAX_LENGTH: 50, | ||
PASSWORD_MAX_LENGTH: 128, | ||
MESSAGE_MAX_LENGTH: 2000, | ||
} as const; | ||
|
||
export function validateInput(input: string, maxLength: number): string { | ||
if (!input || typeof input !== "string") { | ||
throw new Error("Invalid input"); | ||
} | ||
if (input.length > maxLength) { | ||
throw new Error(`Input exceeds maximum length of ${maxLength} characters`); | ||
} | ||
return input.trim(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters