diff --git a/packages/collector/src/announceCycle/unannounced.js b/packages/collector/src/announceCycle/unannounced.js index 33628b65d1..9b3bd20af8 100644 --- a/packages/collector/src/announceCycle/unannounced.js +++ b/packages/collector/src/announceCycle/unannounced.js @@ -9,11 +9,9 @@ const { secrets, tracing, util: { ensureNestedObjectExists }, - coreConfig: { configNormalizers, configValidators } + coreConfig } = require('@instana/core'); -const { validateStackTraceMode, validateStackTraceLength } = configValidators.stackTraceValidation; - const { constants: tracingConstants } = tracing; const agentConnection = require('../agentConnection'); @@ -274,7 +272,8 @@ function applyIgnoreEndpointsConfiguration(agentResponse) { if (!ignoreEndpointsConfig) return; ensureNestedObjectExists(agentOpts.config, ['tracing', 'ignoreEndpoints']); - agentOpts.config.tracing.ignoreEndpoints = configNormalizers.ignoreEndpoints.normalizeConfig(ignoreEndpointsConfig); + agentOpts.config.tracing.ignoreEndpoints = + coreConfig.configNormalizers.ignoreEndpoints.normalizeConfig(ignoreEndpointsConfig); } /** @@ -289,9 +288,9 @@ function applyStackTraceConfiguration(agentResponse) { ensureNestedObjectExists(agentOpts.config, ['tracing', 'global']); if (globalConfig['stack-trace'] !== undefined) { - const stackTraceModeValidation = validateStackTraceMode(globalConfig['stack-trace']); + const stackTraceModeValidation = coreConfig.validate.validateStackTraceMode(globalConfig['stack-trace']); if (stackTraceModeValidation.isValid) { - const normalizedStackTrace = configNormalizers.stackTrace.normalizeStackTraceModeFromAgent( + const normalizedStackTrace = coreConfig.configNormalizers.stackTrace.normalizeStackTraceModeFromAgent( globalConfig['stack-trace'] ); if (normalizedStackTrace != null) { @@ -303,9 +302,9 @@ function applyStackTraceConfiguration(agentResponse) { } if (globalConfig['stack-trace-length'] !== undefined) { - const stackTraceLengthValidation = validateStackTraceLength(globalConfig['stack-trace-length']); + const stackTraceLengthValidation = coreConfig.validate.validateStackTraceLength(globalConfig['stack-trace-length']); if (stackTraceLengthValidation.isValid) { - const normalizedStackTraceLength = configNormalizers.stackTrace.normalizeStackTraceLengthFromAgent( + const normalizedStackTraceLength = coreConfig.configNormalizers.stackTrace.normalizeStackTraceLengthFromAgent( globalConfig['stack-trace-length'] ); if (normalizedStackTraceLength != null) { @@ -330,7 +329,7 @@ function applyDisableConfiguration(agentResponse) { if (!disablingConfig) return; ensureNestedObjectExists(agentOpts.config, ['tracing', 'disable']); - agentOpts.config.tracing.disable = configNormalizers.disable.normalizeExternalConfig({ + agentOpts.config.tracing.disable = coreConfig.configNormalizers.disable.normalizeExternalConfig({ tracing: { disable: disablingConfig } }).value; } diff --git a/packages/core/src/config/configValidators/index.js b/packages/core/src/config/configValidators/index.js deleted file mode 100644 index 3b7bcdf816..0000000000 --- a/packages/core/src/config/configValidators/index.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * (c) Copyright IBM Corp. 2025 - */ - -'use strict'; - -const stackTraceValidation = require('./stackTraceValidation'); - -module.exports.stackTraceValidation = stackTraceValidation; diff --git a/packages/core/src/config/configValidators/stackTraceValidation.js b/packages/core/src/config/configValidators/stackTraceValidation.js deleted file mode 100644 index 94b3aaa4ee..0000000000 --- a/packages/core/src/config/configValidators/stackTraceValidation.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * (c) Copyright IBM Corp. 2025 - */ - -'use strict'; - -const { validStackTraceModes } = require('../../util/constants'); - -/** - * Validates the stack trace mode value. - * - * @param {*} value - The value to validate - * @returns {{ isValid: boolean, error: string | null }} - Validation result - */ -exports.validateStackTraceMode = function validateStackTraceMode(value) { - if (value === null) { - return { isValid: false, error: `The value cannot be null. Valid values are: ${validStackTraceModes.join(', ')}.` }; - } - - if (typeof value !== 'string') { - return { - isValid: false, - error: `The value has the non-supported type ${typeof value}. Valid values are: ${validStackTraceModes.join( - ', ' - )}.` - }; - } - - const normalizedValue = value.toLowerCase(); - if (validStackTraceModes.includes(normalizedValue)) { - return { isValid: true, error: null }; - } - - return { - isValid: false, - error: `Invalid value: "${value}". Valid values are: ${validStackTraceModes.join(', ')}.` - }; -}; - -/** - * Validates the stack trace length value. - * - * @param {*} value - The value to validate - * @returns {{ isValid: boolean, error: string | null }} - Validation result - */ -exports.validateStackTraceLength = function validateStackTraceLength(value) { - if (value == null) { - return { isValid: false, error: 'The value cannot be null' }; - } - - let parsedValue; - - if (typeof value === 'number') { - parsedValue = value; - } else if (typeof value === 'string') { - parsedValue = parseInt(value, 10); - if (isNaN(parsedValue)) { - return { - isValid: false, - error: `The value ("${value}") cannot be parsed to a numerical value.` - }; - } - } else { - return { - isValid: false, - error: `The value has the non-supported type ${typeof value}.` - }; - } - - if (!Number.isFinite(parsedValue)) { - return { - isValid: false, - error: `Invalid value: ${value}. Expected a number or numeric string.` - }; - } - - return { isValid: true, error: null }; -}; diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js index 4042ad8244..76dc72b2c2 100644 --- a/packages/core/src/config/index.js +++ b/packages/core/src/config/index.js @@ -6,12 +6,11 @@ 'use strict'; const configNormalizers = require('./configNormalizers'); -const configValidators = require('./configValidators'); const deepMerge = require('../util/deepMerge'); const { DEFAULT_STACK_TRACE_LENGTH, DEFAULT_STACK_TRACE_MODE, CONFIG_SOURCES } = require('../util/constants'); -const { validateStackTraceMode, validateStackTraceLength } = require('./configValidators/stackTraceValidation'); const util = require('./util'); const validate = require('./validator'); +const { validateStackTraceMode, validateStackTraceLength } = validate; // @typedef {{ [x: string]: any }} configMeta /** @type {configMeta} */ @@ -189,7 +188,7 @@ let defaults = { const validSecretsMatcherModes = ['equals-ignore-case', 'equals', 'contains-ignore-case', 'contains', 'regex', 'none']; module.exports.configNormalizers = configNormalizers; -module.exports.configValidators = configValidators; +module.exports.validate = validate; /** * @param {import('../core').GenericLogger} [_logger] diff --git a/packages/core/src/config/validator.js b/packages/core/src/config/validator.js index a10c82cefe..d0e5837919 100644 --- a/packages/core/src/config/validator.js +++ b/packages/core/src/config/validator.js @@ -4,6 +4,8 @@ 'use strict'; +const { validStackTraceModes } = require('../util/constants'); + /** * @param {any} value * @returns {number|undefined} @@ -49,3 +51,74 @@ exports.validateTruthyBoolean = function validateTruthyBoolean(value) { // Return true if value is truthy, undefined otherwise return value ? true : undefined; }; + +/** + * Validates the stack trace mode value. + * + * @param {*} value - The value to validate + * @returns {{ isValid: boolean, error: string | null }} - Validation result + */ +exports.validateStackTraceMode = function validateStackTraceMode(value) { + if (value === null) { + return { isValid: false, error: `The value cannot be null. Valid values are: ${validStackTraceModes.join(', ')}.` }; + } + + if (typeof value !== 'string') { + return { + isValid: false, + error: `The value has the non-supported type ${typeof value}. Valid values are: ${validStackTraceModes.join( + ', ' + )}.` + }; + } + + const normalizedValue = value.toLowerCase(); + if (validStackTraceModes.includes(normalizedValue)) { + return { isValid: true, error: null }; + } + + return { + isValid: false, + error: `Invalid value: "${value}". Valid values are: ${validStackTraceModes.join(', ')}.` + }; +}; + +/** + * Validates the stack trace length value. + * + * @param {*} value - The value to validate + * @returns {{ isValid: boolean, error: string | null }} - Validation result + */ +exports.validateStackTraceLength = function validateStackTraceLength(value) { + if (value == null) { + return { isValid: false, error: 'The value cannot be null' }; + } + + let parsedValue; + + if (typeof value === 'number') { + parsedValue = value; + } else if (typeof value === 'string') { + parsedValue = parseInt(value, 10); + if (isNaN(parsedValue)) { + return { + isValid: false, + error: `The value ("${value}") cannot be parsed to a numerical value.` + }; + } + } else { + return { + isValid: false, + error: `The value has the non-supported type ${typeof value}.` + }; + } + + if (!Number.isFinite(parsedValue)) { + return { + isValid: false, + error: `Invalid value: ${value}. Expected a number or numeric string.` + }; + } + + return { isValid: true, error: null }; +}; diff --git a/packages/core/test/config/configValidators/stackTraceValidation_test.js b/packages/core/test/config/configValidators/stackTraceValidation_test.js deleted file mode 100644 index a10141d7c3..0000000000 --- a/packages/core/test/config/configValidators/stackTraceValidation_test.js +++ /dev/null @@ -1,255 +0,0 @@ -/* - * (c) Copyright IBM Corp. 2026 - */ - -'use strict'; - -const { expect } = require('chai'); - -const stackTraceValidation = require('../../../src/config/configValidators/stackTraceValidation'); - -describe('config.configValidators.stackTraceValidation', () => { - describe('validateStackTraceMode', () => { - it('should validate "all" as valid', () => { - const result = stackTraceValidation.validateStackTraceMode('all'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate "error" as valid', () => { - const result = stackTraceValidation.validateStackTraceMode('error'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate "none" as valid', () => { - const result = stackTraceValidation.validateStackTraceMode('none'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate uppercase "ALL" as valid', () => { - const result = stackTraceValidation.validateStackTraceMode('ALL'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate mixed case "ErRoR" as valid', () => { - const result = stackTraceValidation.validateStackTraceMode('ErRoR'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate mixed case "NoNe" as valid', () => { - const result = stackTraceValidation.validateStackTraceMode('NoNe'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should reject null value', () => { - const result = stackTraceValidation.validateStackTraceMode(null); - expect(result.isValid).to.be.false; - expect(result.error).to.include('cannot be null'); - }); - - it('should reject invalid string value', () => { - const result = stackTraceValidation.validateStackTraceMode('invalid'); - expect(result.isValid).to.be.false; - expect(result.error).to.include('Invalid value: "invalid"'); - }); - - it('should reject number type', () => { - const result = stackTraceValidation.validateStackTraceMode(123); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type number'); - }); - - it('should reject boolean type', () => { - const result = stackTraceValidation.validateStackTraceMode(true); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type boolean'); - }); - - it('should reject object type', () => { - const result = stackTraceValidation.validateStackTraceMode({}); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type object'); - }); - - it('should reject array type', () => { - const result = stackTraceValidation.validateStackTraceMode(['error']); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type object'); - }); - - it('should reject undefined value', () => { - const result = stackTraceValidation.validateStackTraceMode(undefined); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type undefined'); - }); - - it('should reject empty string', () => { - const result = stackTraceValidation.validateStackTraceMode(''); - expect(result.isValid).to.be.false; - expect(result.error).to.include('Invalid value: ""'); - }); - - it('should reject string with only whitespace', () => { - const result = stackTraceValidation.validateStackTraceMode(' '); - expect(result.isValid).to.be.false; - expect(result.error).to.include('Invalid value'); - }); - }); - - describe('validateStackTraceLength', () => { - it('should validate positive number', () => { - const result = stackTraceValidation.validateStackTraceLength(10); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate zero', () => { - const result = stackTraceValidation.validateStackTraceLength(0); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate negative number', () => { - const result = stackTraceValidation.validateStackTraceLength(-10); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate large number', () => { - const result = stackTraceValidation.validateStackTraceLength(1000); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate decimal number', () => { - const result = stackTraceValidation.validateStackTraceLength(15.7); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate numeric string', () => { - const result = stackTraceValidation.validateStackTraceLength('20'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate negative numeric string', () => { - const result = stackTraceValidation.validateStackTraceLength('-15'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate decimal numeric string', () => { - const result = stackTraceValidation.validateStackTraceLength('12.5'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate numeric string with leading zeros', () => { - const result = stackTraceValidation.validateStackTraceLength('007'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate numeric string with whitespace', () => { - const result = stackTraceValidation.validateStackTraceLength(' 25 '); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should validate numeric string with plus sign', () => { - const result = stackTraceValidation.validateStackTraceLength('+30'); - expect(result.isValid).to.be.true; - expect(result.error).to.be.null; - }); - - it('should reject null value', () => { - const result = stackTraceValidation.validateStackTraceLength(null); - expect(result.isValid).to.be.false; - expect(result.error).to.equal('The value cannot be null'); - }); - - it('should reject undefined value', () => { - const result = stackTraceValidation.validateStackTraceLength(undefined); - expect(result.isValid).to.be.false; - expect(result.error).to.equal('The value cannot be null'); - }); - - it('should reject non-numeric string', () => { - const result = stackTraceValidation.validateStackTraceLength('invalid'); - expect(result.isValid).to.be.false; - expect(result.error).to.include('cannot be parsed to a numerical value'); - }); - - it('should reject empty string', () => { - const result = stackTraceValidation.validateStackTraceLength(''); - expect(result.isValid).to.be.false; - expect(result.error).to.include('cannot be parsed to a numerical value'); - }); - - it('should reject boolean type', () => { - const result = stackTraceValidation.validateStackTraceLength(true); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type boolean'); - }); - - it('should reject object type', () => { - const result = stackTraceValidation.validateStackTraceLength({}); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type object'); - }); - - it('should reject array type', () => { - const result = stackTraceValidation.validateStackTraceLength([10]); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type object'); - }); - - it('should reject Infinity', () => { - const result = stackTraceValidation.validateStackTraceLength(Infinity); - expect(result.isValid).to.be.false; - expect(result.error).to.include('Invalid value: Infinity'); - }); - - it('should reject -Infinity', () => { - const result = stackTraceValidation.validateStackTraceLength(-Infinity); - expect(result.isValid).to.be.false; - expect(result.error).to.include('Invalid value: -Infinity'); - }); - - it('should reject NaN', () => { - const result = stackTraceValidation.validateStackTraceLength(NaN); - expect(result.isValid).to.be.false; - expect(result.error).to.include('Invalid value: NaN'); - }); - - it('should reject string "Infinity"', () => { - const result = stackTraceValidation.validateStackTraceLength('Infinity'); - expect(result.isValid).to.be.false; - expect(result.error).to.include('cannot be parsed'); - }); - - it('should reject string "NaN"', () => { - const result = stackTraceValidation.validateStackTraceLength('NaN'); - expect(result.isValid).to.be.false; - expect(result.error).to.include('cannot be parsed to a numerical value'); - }); - - it('should reject function type', () => { - const result = stackTraceValidation.validateStackTraceLength(() => 10); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type function'); - }); - - it('should reject symbol type', () => { - const result = stackTraceValidation.validateStackTraceLength(Symbol('test')); - expect(result.isValid).to.be.false; - expect(result.error).to.include('non-supported type symbol'); - }); - }); -}); diff --git a/packages/core/test/config/validator_test.js b/packages/core/test/config/validator_test.js index 6a5204b94e..13ef8e506d 100644 --- a/packages/core/test/config/validator_test.js +++ b/packages/core/test/config/validator_test.js @@ -172,4 +172,250 @@ describe('config.validator', () => { expect(validator.validateTruthyBoolean(NaN)).to.be.undefined; }); }); + + describe('config.validator.validator', () => { + describe('validateStackTraceMode', () => { + it('should validator "all" as valid', () => { + const result = validator.validateStackTraceMode('all'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator "error" as valid', () => { + const result = validator.validateStackTraceMode('error'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator "none" as valid', () => { + const result = validator.validateStackTraceMode('none'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator uppercase "ALL" as valid', () => { + const result = validator.validateStackTraceMode('ALL'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator mixed case "ErRoR" as valid', () => { + const result = validator.validateStackTraceMode('ErRoR'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator mixed case "NoNe" as valid', () => { + const result = validator.validateStackTraceMode('NoNe'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should reject null value', () => { + const result = validator.validateStackTraceMode(null); + expect(result.isValid).to.be.false; + expect(result.error).to.include('cannot be null'); + }); + + it('should reject invalid string value', () => { + const result = validator.validateStackTraceMode('invalid'); + expect(result.isValid).to.be.false; + expect(result.error).to.include('Invalid value: "invalid"'); + }); + + it('should reject number type', () => { + const result = validator.validateStackTraceMode(123); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type number'); + }); + + it('should reject boolean type', () => { + const result = validator.validateStackTraceMode(true); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type boolean'); + }); + + it('should reject object type', () => { + const result = validator.validateStackTraceMode({}); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type object'); + }); + + it('should reject array type', () => { + const result = validator.validateStackTraceMode(['error']); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type object'); + }); + + it('should reject undefined value', () => { + const result = validator.validateStackTraceMode(undefined); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type undefined'); + }); + + it('should reject empty string', () => { + const result = validator.validateStackTraceMode(''); + expect(result.isValid).to.be.false; + expect(result.error).to.include('Invalid value: ""'); + }); + + it('should reject string with only whitespace', () => { + const result = validator.validateStackTraceMode(' '); + expect(result.isValid).to.be.false; + expect(result.error).to.include('Invalid value'); + }); + }); + + describe('validateStackTraceLength', () => { + it('should validator positive number', () => { + const result = validator.validateStackTraceLength(10); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator zero', () => { + const result = validator.validateStackTraceLength(0); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator negative number', () => { + const result = validator.validateStackTraceLength(-10); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator large number', () => { + const result = validator.validateStackTraceLength(1000); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator decimal number', () => { + const result = validator.validateStackTraceLength(15.7); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator numeric string', () => { + const result = validator.validateStackTraceLength('20'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator negative numeric string', () => { + const result = validator.validateStackTraceLength('-15'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator decimal numeric string', () => { + const result = validator.validateStackTraceLength('12.5'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator numeric string with leading zeros', () => { + const result = validator.validateStackTraceLength('007'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator numeric string with whitespace', () => { + const result = validator.validateStackTraceLength(' 25 '); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should validator numeric string with plus sign', () => { + const result = validator.validateStackTraceLength('+30'); + expect(result.isValid).to.be.true; + expect(result.error).to.be.null; + }); + + it('should reject null value', () => { + const result = validator.validateStackTraceLength(null); + expect(result.isValid).to.be.false; + expect(result.error).to.equal('The value cannot be null'); + }); + + it('should reject undefined value', () => { + const result = validator.validateStackTraceLength(undefined); + expect(result.isValid).to.be.false; + expect(result.error).to.equal('The value cannot be null'); + }); + + it('should reject non-numeric string', () => { + const result = validator.validateStackTraceLength('invalid'); + expect(result.isValid).to.be.false; + expect(result.error).to.include('cannot be parsed to a numerical value'); + }); + + it('should reject empty string', () => { + const result = validator.validateStackTraceLength(''); + expect(result.isValid).to.be.false; + expect(result.error).to.include('cannot be parsed to a numerical value'); + }); + + it('should reject boolean type', () => { + const result = validator.validateStackTraceLength(true); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type boolean'); + }); + + it('should reject object type', () => { + const result = validator.validateStackTraceLength({}); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type object'); + }); + + it('should reject array type', () => { + const result = validator.validateStackTraceLength([10]); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type object'); + }); + + it('should reject Infinity', () => { + const result = validator.validateStackTraceLength(Infinity); + expect(result.isValid).to.be.false; + expect(result.error).to.include('Invalid value: Infinity'); + }); + + it('should reject -Infinity', () => { + const result = validator.validateStackTraceLength(-Infinity); + expect(result.isValid).to.be.false; + expect(result.error).to.include('Invalid value: -Infinity'); + }); + + it('should reject NaN', () => { + const result = validator.validateStackTraceLength(NaN); + expect(result.isValid).to.be.false; + expect(result.error).to.include('Invalid value: NaN'); + }); + + it('should reject string "Infinity"', () => { + const result = validator.validateStackTraceLength('Infinity'); + expect(result.isValid).to.be.false; + expect(result.error).to.include('cannot be parsed'); + }); + + it('should reject string "NaN"', () => { + const result = validator.validateStackTraceLength('NaN'); + expect(result.isValid).to.be.false; + expect(result.error).to.include('cannot be parsed to a numerical value'); + }); + + it('should reject function type', () => { + const result = validator.validateStackTraceLength(() => 10); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type function'); + }); + + it('should reject symbol type', () => { + const result = validator.validateStackTraceLength(Symbol('test')); + expect(result.isValid).to.be.false; + expect(result.error).to.include('non-supported type symbol'); + }); + }); + }); });