@e-group/utils
Version:
eGroup team utils that share across projects.
18 lines (17 loc) • 707 B
JavaScript
/**
* Check if object keys with null or undefined value(Shallow).
*/
export default 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;
}