Add: isValidPlayerID, isValidPlayerPW
This commit is contained in:
@@ -3,8 +3,12 @@ class AccountValidator {
|
||||
constructor() {
|
||||
this.patternMaestroID = /^[A-Za-z]{1}[A-Za-z0-9]{3,19}$/;
|
||||
this.patternMaestroPW = /^[A-Za-z0-9]{4,16}$/;
|
||||
|
||||
this.patternPlayerID = /^[A-Za-z0-9가-힣-_]{1,8}$/;
|
||||
this.patternPlayerPW = /^[0-9]{4,6}$/;
|
||||
}
|
||||
|
||||
// maestro
|
||||
isValidMaestroID(textID) {
|
||||
if(!this.patternMaestroID.test(textID))
|
||||
return false;
|
||||
@@ -44,6 +48,46 @@ class AccountValidator {
|
||||
}
|
||||
|
||||
|
||||
// player
|
||||
isValidPlayerID(textID) {
|
||||
if(!this.patternPlayerID.test(textID))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
messageForInvalidPlayerID(textID) {
|
||||
if(textID.length < AccountValidator.Player_ID_LENGTH_MINIMUM)
|
||||
return "마에스트로 계정명은 " + AccountValidator.Player_ID_LENGTH_MINIMUM + "글자 이상이어야 합니다.";
|
||||
else if(textID.length > AccountValidator.Player_ID_LENGTH_MAXIMUM)
|
||||
return "마에스트로 계정명은 " + AccountValidator.Player_ID_LENGTH_MAXIMUM + "글자 이하이어야 합니다.";
|
||||
else if(!(/^[A-Za-z]/.test(textID)))
|
||||
return "마에스트로 계정명은 알파벳으로 시작해야 합니다.";
|
||||
else if((/[^\w]/g).test(textID))
|
||||
return "마에스트로 계정명은 알파벳과 숫자로만 적어주세요.";
|
||||
}
|
||||
|
||||
|
||||
isValidPlayerPW(textPW) {
|
||||
if(!this.patternPlayerPW.test(textPW))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
messageForInvalidPlayerPW(textPW) {
|
||||
console.log(textPW);
|
||||
if(textPW.length < AccountValidator.Player_PW_LENGTH_MINIMUM)
|
||||
return "마에스트로의 암호는 " + AccountValidator.Player_PW_LENGTH_MINIMUM + "글자 이상이어야 합니다.";
|
||||
else if(textPW.length > AccountValidator.Player_PW_LENGTH_MAXIMUM)
|
||||
return "마에스트로의 암호는 " + AccountValidator.Player_PW_LENGTH_MAXIMUM + "글자 이하이어야 합니다.";
|
||||
else if((/[^\w]/g).test(textPW))
|
||||
return "마에스트로의 암호는 알파벳과 숫자로만 적어주세요.";
|
||||
else
|
||||
return "???";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,4 +95,11 @@ AccountValidator.MAESTRO_ID_LENGTH_MINIMUM = 4;
|
||||
AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM = 20;
|
||||
|
||||
AccountValidator.MAESTRO_PW_LENGTH_MINIMUM = 4;
|
||||
AccountValidator.MAESTRO_PW_LENGTH_MAXIMUM = 16;
|
||||
AccountValidator.MAESTRO_PW_LENGTH_MAXIMUM = 16;
|
||||
|
||||
|
||||
AccountValidator.PLAYER_ID_LENGTH_MINIMUM = 1;
|
||||
AccountValidator.PLAYER_ID_LENGTH_MAXIMUM = 8;
|
||||
|
||||
AccountValidator.PLAYER_PW_LENGTH_MINIMUM = 4;
|
||||
AccountValidator.PLAYER_PW_LENGTH_MAXIMUM = 6;
|
||||
Reference in New Issue
Block a user