-
-
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 user information input validation
Signed-off-by: cbh778899 <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 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,21 @@ | ||
export const email_not_valid = 'Email pattern not valid!'; | ||
export const password_not_valid = 'Password should have at least 8 characters combines capital letters, lowercase letters, numbers and special characters.'; | ||
export const username_not_valid = 'Username should includes only letters, numbers, -, _ and white space, no less than 4 characters and no more than 20 characters.'; | ||
|
||
export function validateEmail(string) { | ||
return ( | ||
/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(string) | ||
) | ||
} | ||
|
||
export function validatePassword(string) { | ||
return ( | ||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()-_+=])[a-zA-Z\d!@#$%^&*()-_+=]{8,}$/.test(string) | ||
Check warning Code scanning / CodeQL Overly permissive regular expression range Medium
Suspicious character range that is equivalent to \[)*+,\-.\/0-9:;<=>?@A-Z\\[\\\\]^_\].
Check warning Code scanning / CodeQL Overly permissive regular expression range Medium
Suspicious character range that overlaps with \d in the same character class, and overlaps with A-Z in the same character class, and is equivalent to \[)*+,\-.\/0-9:;<=>?@A-Z\\[\\\\]^_\].
|
||
) | ||
} | ||
|
||
export function validateUsername(string) { | ||
return ( | ||
/^[a-zA-Z0-9-_ ]{4,20}$/.test(string) | ||
) | ||
} |