createTypeEnum<
T>(enumList):WritableWithDefaultOptions<T>
Build an enum normalizer
T
the enum type
T[]
list of enum values to check
the enum normalizer
testToNormalizeValue<
T>(filter): (value) => typeofINVALID_VALUE|T
Check if a value respects a provided type guard.
T
The type that the filter function validates.
(value) => value is T
A function that takes a value and returns a boolean indicating whether the value is of type T.
A function that takes a value and returns the value if it passes the filter,
otherwise returns INVALID_VALUE.
(
value): typeofINVALID_VALUE|T
any
typeof INVALID_VALUE | T
consttypeArray:WritableWithDefaultOptions<any[]>
A writable object with default options for handling arrays.
consttypeBoolean:WritableWithDefaultOptions<boolean>
A writable object with default options for boolean values.
This object provides a normalized way to handle boolean values
using the WritableWithDefaultOptions interface. The normalizeValue
function ensures that the value is properly validated and normalized
as a boolean.
consttypeBooleanOrNull:WritableWithDefaultOptions<boolean|null>
A writable with default options that normalizes its value to a boolean or null.
This writable uses a normalization function that allows null values and ensures the value is a boolean.
consttypeFunction:WritableWithDefaultOptions<(...args) =>any>
A writable object that holds a function type with default options.
consttypeHTMLElementOrNull:WritableWithDefaultOptions<HTMLElement|null>
A writable object with default options for handling values of type HTMLElement or null.
This object provides:
normalizeValue: A function to normalize the value, ensuring it is either an HTMLElement or null.equal: A function to compare two values for equality using Object.is.
consttypeNumber:WritableWithDefaultOptions<number>
A writable object with default options for handling numbers.
typeNumberInRangeFactory(
min,max,options):WritableWithDefaultOptions<number>
Factory function for creating a type constraint for numbers within a specified range.
number
The minimum value.
number
The maximum value.
Additional options to customize the behavior.
WritableWithDefaultOptions<number>
A type guard function that returns the clamp value or INVALID_VALUE depending on the provided options.
Options for specifying the behavior of number range validation.
optionalstrict:boolean
If true, the range checking will be strict, excluding the minimum and maximum values. Default is false.
optionaluseClamp:boolean
If true, values outside the range will be clamped to the minimum or maximum. Default is true.
consttypeString:WritableWithDefaultOptions<string>
A writable object with default options for string values.
This object provides a normalized value for strings using the testToNormalizeValue function
with the isString validator.
consttypeStringOrNull:WritableWithDefaultOptions<string|null>
A writable with default options that normalizes its value to a string or null.
This object provides a normalized value for strings using the testToNormalizeValue function
with the isString validator.