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 "???";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -52,3 +96,10 @@ AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM = 20;
|
||||
|
||||
AccountValidator.MAESTRO_PW_LENGTH_MINIMUM = 4;
|
||||
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;
|
||||
+86
-7
@@ -25,7 +25,6 @@ QUnit.test( "AccountValidator - isValidMaestroID", function( assert ) {
|
||||
|
||||
QUnit.test( "AccountValidator - isValidMaestroPW", function( assert ) {
|
||||
let text = "";
|
||||
text = "";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
text = "1";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
@@ -39,25 +38,105 @@ QUnit.test( "AccountValidator - isValidMaestroPW", function( assert ) {
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
|
||||
text = "123456";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
|
||||
text = "1234567";
|
||||
text = "1234567891234567";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
|
||||
text = "12345678912345678";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - no text");
|
||||
text = "1abcde";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
|
||||
text = "abc";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
text = "a1b";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
text = "abcdeabcdeabcdeabcdea";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
text = "abcdeabcdeabcdeabcde";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
});
|
||||
|
||||
|
||||
QUnit.test( "AccountValidator - isValidPlayerID", function( assert ) {
|
||||
let text = "";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - no text");
|
||||
text = "1abcde";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "abc";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "a1b";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "abcdeabcdeabcdeabcdea";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
|
||||
|
||||
text = "abcd";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "aA1Bccd";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "abcdeabcdeabcdeabcde";
|
||||
assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroID - " + text);
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
|
||||
|
||||
text = "박지상";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "박지상76";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "박";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "ㅂ";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
|
||||
|
||||
text = "박지상박세나";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "박지상박세나신현";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "박지상박세나ab";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "박지상박세나abc";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
|
||||
text = "박지상박세나신현주";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
|
||||
text = "박지상박세나123";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
|
||||
|
||||
text = "1-3박세나";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
|
||||
text = "1-4 박지상";
|
||||
assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
|
||||
});
|
||||
|
||||
QUnit.test( "AccountValidator - isValidPlayerPW", function( assert ) {
|
||||
let text = "";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "1";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "12";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "123";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "1234";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), true, "isValidPlayerPW - " + text);
|
||||
text = "12345";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), true, "isValidPlayerPW - " + text);
|
||||
text = "123456";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), true, "isValidPlayerPW - " + text);
|
||||
text = "1234567";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - no text");
|
||||
text = "1abcde";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "abc";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "a1b";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "abcdeabcdeabcdeabcdea";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
|
||||
text = "abcd";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "aA1Bccd";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
text = "abcdeabcdeabcdeabcde";
|
||||
assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user