isStringNullOrEmpty(val) || val. replace(/\s/g, “”) === ”; } , //If string is null or empty then return Null or else original value nullIfStringNullOrEmpty: function (val) { if (this. isStringNullOrEmpty(val)) { return null; } return val; } }, Utilize this helpers to achieve that.