Skip to content

optional

optional<S, E>(spec, defaultValue?): FormatSpec<S, E>

Defined in: extract/spec.ts:703

Make any spec optional. Failures return the default value (or undefined if none provided) instead of failing.

For ExtractSpec, sets the optional flag directly. For all other spec kinds, desugars to tryExtract(spec, literal(default)).

Works universally across all formats and all failure kinds.

S

E

FormatSpec<S, E>

unknown

FormatSpec<S, E>

optional(row.colWhere(header, cell.equals('Ownership')).number(), null)
optional(someObjectSpec, null)

optional(spec, defaultValue?): Spec

Defined in: extract/spec.ts:707

Make any spec optional. Failures return the default value (or undefined if none provided) instead of failing.

For ExtractSpec, sets the optional flag directly. For all other spec kinds, desugars to tryExtract(spec, literal(default)).

Works universally across all formats and all failure kinds.

SpecLike

unknown

Spec

optional(row.colWhere(header, cell.equals('Ownership')).number(), null)
optional(someObjectSpec, null)