Skip to content

FormatFieldValue

cartographer


cartographer / formatFieldValue

formatFieldValue(value, fieldType): string

Defined in: types/types.ts:170

Format field value for display in UI. Converts values to human-readable string representation based on type.

The value to format

string | number | boolean | string[] | Date | null | undefined

string

The field type (determines formatting)

string

  • Formatted string suitable for display, or ’-’ if null/undefined
const dateStr = formatFieldValue(new Date('2026-01-06'), 'date'); // Returns: '1/6/2026'
const boolStr = formatFieldValue(true, 'boolean'); // Returns: '✓'
const arrStr = formatFieldValue(['a', 'b'], 'array'); // Returns: 'a, b'
const nullStr = formatFieldValue(null, 'string'); // Returns: '-'