1var valid = { 2 // null & undefined & 공백 ì²´í¬ 3 checkNull : function(str) { 4 if(typeof str == "undefined" || str == null || str == ""){ 5 return true; 6 } else{ 7 return false; 8 } 9 }, 10 11 // Objectê° ë¹ì´ìì ë true ë°í 12 checkEmptyObject : function(obj) { 13 if(typeof obj == "string") { 14 obj = JSON.parse(obj); 15 } 16 17 if(Object.keys(obj).length === 0 && JSON.stringify(obj) === JSON.stringify({})){ 18 return true; 19 } else{ 20 return false; 21 } 22 }, 23 24 // null & undefined (공백ì ê·¸ë¥ ëì´ê°) 25 checkUndefined: function(str) { 26 if(typeof str == "undefined" || str == null){ 27 return true; 28 } else{ 29 return false; 30 } 31 }, 32 33 // ê°ì´ ìê±°ë("") í¹ì 공백(" ")ë§ ìëì§ ì²´í¬ 34 checkEmpty : function(str) { 35 if(str == "" || str.replace(/ /gi, "") == ""){ 36 return true; 37 } else{ 38 return false; 39 } 40 }, 41 42 // í¹ì 문ìê° ì¡´ì¬íëì§ ì²´í¬íì¬ í´ë¹ ì¸ë±ì¤ ë¦¬í´ 43 checkContains : function(str, char) { 44 for(let i = 0; i < str.length; i++) { 45 if(char.indexOf(str.charAt(i)) != -1) { 46 return i; 47 } 48 } 49 50 return false; 51 }, 52 53 // ë°ì´í¸ ì ë°í 54 checkBytes : function(str) { 55 return str.replace(/[\0-\x7f]|([0-\u07ff]|(.))/g,"$&$1$2").length; 56 }, 57 58 // ì«ì ì²´í¬ 59 checkNumber : function(str) { 60 if(/^[0-9]*$/.test(str) && !valid.checkNull(str)){ 61 return true; 62 } else{ 63 return false; 64 } 65 }, 66 67 // 문ìì´ ê¸¸ì´ ì²´í¬ 68 checkLength : function(str, length) { 69 if(str.length == length && !valid.checkNull(str)){ 70 return true; 71 } else{ 72 return false; 73 } 74 }, 75 76 // íê¸ ì²´í¬ 77 checkKorean : function(str) { 78 if(/^[\uac00-\ud7a3+\u3131-\u314E+\u314F-\u3163]*$/.test(str) && !valid.checkNull(str)){ 79 return true; 80 } else{ 81 return false; 82 } 83 }, 84 85 // ìì´ ì²´í¬ 86 checkEnglish : function(str) { 87 if(/^[a-zA-Z]*$/.test(str) && !valid.checkNull(str)){ 88 return true; 89 } else{ 90 return false; 91 } 92 }, 93 94 // ìì´ + ì«ì ì²´í¬ 95 checkEnglishNum : function(str) { 96 if(/^[a-zA-Z0-9]*$/.test(str) && !valid.checkNull(str)){ 97 return true; 98 } else{ 99 return false; 100 } 101 }, 102 103 // ì íë²í¸ ì²´í¬ 104 checkTelNum : function(str) { 105 if(/^\d{2,3}-\d{3,4}-\d{4}$/.test(str)){ 106 return true; 107 } else{ 108 return false; 109 } 110 }, 111 112 // 주민ë±ë¡ë²í¸ ì²´í¬ 113 checkRnum : function(str) { 114 if(/^\d{6} \- [1-4]\d{6}/.test(str)){ 115 return true; 116 } else{ 117 return false; 118 } 119 }, 120 121 // ì´ë©ì¼ ì²´í¬ 122 checkEmail : function(str) { 123 if(/^[A-Za-z0-9_\.\-]+@[A-Za-z0-9\-]+\.[A-Za-z0-9\-]+/.test(str)){ 124 return true; 125 } else{ 126 return false; 127 } 128 }, 129 130 // ë ì§ ì²´í¬ yyyy-MM-dd 131 checkDateYmd : function(str) { 132 if(!valid.checkNull(str) && /^(19|20)\d{2}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[0-1])$/.test(str)){ 133 if(this.validDate(str)) { 134 return true; 135 } else { 136 return false; 137 } 138 } else{ 139 return false; 140 } 141 }, 142 143 // ë ì§ ì í¨ì± ì²´í¬ 144 validDate : function(str) { 145 var dtArray = str.split("-"); 146 dtYear = dtArray[0]; 147 dtMonth = dtArray[1]; 148 dtDay = dtArray[2]; 149 150 if (dtMonth < 1 || dtMonth > 12) { 151 return false; 152 } 153 else if (dtDay < 1 || dtDay > 31) { 154 return false; 155 } 156 else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31) { 157 return false; 158 } 159 else if (dtMonth == 2) { 160 var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0)); 161 if (dtDay > 29 || (dtDay == 29 && !isleap)) { 162 return false; 163 } 164 } 165 return true; 166 } 167}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.