@e-group/utils
Version:
eGroup team utils that share across projects.
25 lines (22 loc) • 808 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = objectCheckNull;
/**
* Check if object keys with null or undefined value(Shallow).
*/
function objectCheckNull(obj, options) {
const _ref = options || {},
checkEmptyString = _ref.checkEmptyString,
checkZero = _ref.checkZero,
checkFalse = _ref.checkFalse;
const originLength = Object.keys(obj).length;
const vaildLength = Object.values(obj).filter(el => {
const conditionEmptyString = checkEmptyString ? el !== "" : true;
const conditionZero = checkZero ? el !== 0 : true;
const conditionFalse = checkFalse ? el !== false : true;
return el != null && conditionEmptyString && conditionZero && conditionFalse;
}).length;
return originLength !== vaildLength;
}