Skip to content

ParseFieldValue

cartographer


cartographer / parseFieldValue

parseFieldValue(value, fieldType): string | number | boolean | string[] | Date | null

Defined in: types/types.ts:129

Parse field value based on its type definition. Coerces values to the correct type (number, boolean, date, array, etc.).

The raw value to parse

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

string

The target field type (determines coercion logic)

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

  • Parsed value of the correct type, or null if value is null/undefined
const num = parseFieldValue('5000', 'number'); // Returns: 5000
const bool = parseFieldValue('true', 'boolean'); // Returns: true
const date = parseFieldValue('2026-01-06', 'date'); // Returns: Date object
const arr = parseFieldValue('item1', 'array'); // Returns: ['item1']