isEmpty js 로직 수정... 추후 테스트 필요

dev
박성영 3 months ago
parent cbd9ed47a7
commit 226da61230

@ -194,7 +194,27 @@ $(document).ready(function () {
* @returns {boolean}
*/
function isEmpty(value) {
var isEmptyObject = function(a) {
if (value === null || value === undefined) {
return true;
}
if (typeof value === 'string' && value.trim() === '') {
return true;
}
if (Array.isArray(value) && value.length === 0) {
return true;
}
if (typeof value === 'object' && Object.keys(value).length === 0) {
return true;
}
return false;
/*
기존소스 주석. 0 true 이닌 false 처리
var isEmptyObject = function(a) {
if(typeof a.length === 'undefined') { // it's an Object, not an Array
var hasNonempty = Object.keys(a).some(function nonEmpty(element) {
return !isEmpty(a[element]);
@ -208,6 +228,7 @@ function isEmpty(value) {
});
};
return(value == false || typeof value === 'undefined' || value == null || (typeof value === 'object' && isEmptyObject(value)));
*/
}
/**
* null 이나 빈값을 기본값으로 변경

@ -130,6 +130,7 @@ function validateByAttribute(element) {
switch (type) {
case 'required':
if (isEmpty(value)) {
console.log(value, isEmpty(value));
isValid = false;
errorMessage = '필수 입력 항목입니다.';
}
@ -347,7 +348,7 @@ function getByteLength(str) {
}
/**
* 값이 비어있는지 확인합니다.
* 값이 비어있는지 확인합니다., common_util.js 있는거 사용
*
* @param {*} value - 검증할
* @returns {boolean} - 값이 비어있으면 true, 그렇지 않으면 false
@ -368,7 +369,6 @@ function isEmpty(value) {
if (typeof value === 'object' && Object.keys(value).length === 0) {
return true;
}
return false;
}

Loading…
Cancel
Save