UNPKG

guardz

Version:

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

18 lines (17 loc) 742 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reportTypeGuardError = reportTypeGuardError; const generateTypeGuardError_1 = require("../typeguards/generateTypeGuardError"); /** * Reports a type guard error if configuration is provided. * This utility function centralizes error reporting logic to avoid code duplication. * * @param config - Optional configuration for error handling * @param value - The value that failed validation * @param expectedType - The expected type name */ function reportTypeGuardError(config, value, expectedType) { if (config) { config.callbackOnError((0, generateTypeGuardError_1.generateTypeGuardError)(value, config.identifier, expectedType)); } }