12 lines
399 B
TypeScript
12 lines
399 B
TypeScript
export const passwordRegex =
|
|
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{8,}$/;
|
|
|
|
export const passwordHelp =
|
|
'Must be 8+ characters and include uppercase, lowercase, a number, and a special character (!@#$%^&*).';
|
|
|
|
export function validatePassword(pw: string): string | null {
|
|
if (!pw) return 'Password is required.';
|
|
if (!passwordRegex.test(pw)) return passwordHelp;
|
|
return null;
|
|
}
|