UNPKG

guardz

Version:

A simple and lightweight TypeScript type guard library for runtime type validation.

21 lines (20 loc) 807 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isNonNullObject = void 0; const generateTypeGuardError_1 = require("./generateTypeGuardError"); /** * Checks if a value is a non-null object. * * @param [value] - The value to check. * @param [config] - The effect of invalid type. * @returns {boolean} Returns true if the value is a non-null object, otherwise false. */ const isNonNullObject = function (value, config) { // Exclude arrays const isValid = typeof value === 'object' && value !== null && !Array.isArray(value); if (!isValid && config) { config.callbackOnError((0, generateTypeGuardError_1.generateTypeGuardError)(value, config.identifier, 'non-null object')); } return isValid; }; exports.isNonNullObject = isNonNullObject;