Skip to main content

fromNumber(params): string

Defined in: src/config-manager/converters.ts:100

Validates and converts a numeric value to string format for environment variables. Ensures the value is a valid number (not NaN or Infinity) before converting to string.

Parameters​

params​

The parameters object

value​

number

The numeric value to validate and convert

variableName​

string

The name of the environment variable (used in error messages)

Returns​

string

The number converted to string format

Throws​

When the value is not a valid number (NaN, Infinity, etc.)

Example​

const validated = fromNumber({
variableName: 'PORT',
value: 3000
});
// Returns: "3000"

const timeout = fromNumber({
variableName: 'TIMEOUT',
value: 30.5
});
// Returns: "30.5"