Skip to content

@eightkk/vue-weave / core / parseFieldValue

Function: parseFieldValue() ​

parseFieldValue(spec, text): FieldParseResult

Defined in: src/core/fieldEditing.ts:407

Read editor text into a field value. Empty text (after trimming) is null, or a required error; 0 and negative numbers are values, not empty. The result is also checked with validateFieldValue.

The built-in parsers read what formatFieldValue writes, so formatting a valid value and parsing the text gives the same value back:

  • select: a choice's label, or its value. A label that exactly one choice shows wins over a value. Text that matches several choices (a shared label with no single matching value) is a choice error; the formatter then shows values instead. With multiple, the text is split at unquoted commas into an array, in order. An entry in double quotes ("Cut, weld", with "" for a quote inside) is read exactly, commas and surrounding whitespace included; unquoted entries are trimmed. An empty unquoted entry (a,,b) or an unclosed quote is invalid. Throws an Error when some choice has no text that names it (its label and value both read as other choices).
  • time with timeZone: a trailing offset (-05:00, Z) picks one occurrence of a repeated wall time; without one, the earlier occurrence is used.

Parameters ​

spec ​

TimelineFieldSpec<any>

text ​

string

Returns ​

FieldParseResult

Released under the MIT License.