- 기능 구현 1차 완료(동작 확인 필요)
This commit is contained in:
@@ -1,7 +1,22 @@
|
||||
export class Validator {
|
||||
static isEmail = (value: any) => {
|
||||
if (typeof value !== 'string') return false;
|
||||
const email = value.trim();
|
||||
return /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(email);
|
||||
};
|
||||
if (typeof value !== 'string') return false;
|
||||
const email = value.trim();
|
||||
return /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(email);
|
||||
};
|
||||
|
||||
static validatePasswordFormat = (password: string): boolean => {
|
||||
if (password.length < 8) return false;
|
||||
|
||||
const alphabets = 'abcdefghijklmnopqrstuvwxyz';
|
||||
const numbers = '0123456789';
|
||||
const specials = '!@#$%^';
|
||||
|
||||
if (!alphabets.includes(password[0])) return false;
|
||||
|
||||
const hasNumber = [...numbers].some((char) => password.includes(char));
|
||||
const hasSpecial = [...specials].some((char) => password.includes(char));
|
||||
|
||||
return hasNumber && hasSpecial;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user