Skip to content

API reference / @localizer/format-lookup / lookupFormatter

Function: lookupFormatter()
preview
​

lookupFormatter<T>(lut): ValueFormatter<T>

Defined in: lookupFormatter.ts:91

Creates a formatter that selects formatting logic based on the input value.

Special symbols (NoValue, UndefinedValue, NullValue, DefaultValue) handle cases like undefined, null, or fallback values.

Type Parameters ​

Type ParameterDescription
TThe type of values the formatter supports.

Parameters ​

ParameterTypeDescription
lutLookupTable<T>Lookup table mapping values to localizable content or formatters.

Returns ​

ValueFormatter<T>

A function that formats the input value using the lookup table.

Throws ​

If the value is not in the lookup table and no default is specified.