Skip to content

FluentSpec

Defined in: extract/spec.ts:249

Chainable wrapper for spec combinators. Replaces nested mapSpec(guard(tryExtract(...))) with .map().guard().or().

Unwrapped automatically wherever a SpecLike is accepted.

fluent(row.colWhere(header, cell.equals('Amount')).string())
.map(v => parseFloat(v as string), 'parseFloat')
.guard(v => (v as number) > 0, 'Must be positive')
.or(literal(0))

T extends Spec

new FluentSpec<T>(spec): FluentSpec<T>

Defined in: extract/spec.ts:250

T

FluentSpec<T>

readonly spec: T

Defined in: extract/spec.ts:250

guard(predicate, reason?): FluentSpec<GuardSpec<T>>

Defined in: extract/spec.ts:260

(v) => boolean

string

FluentSpec<GuardSpec<T>>


map<Out>(fn, desc?, schemaHint?): FluentSpec<MapSpec<T, Out>>

Defined in: extract/spec.ts:252

Out

(v) => Out

string

Record<string, unknown>

FluentSpec<MapSpec<T, Out>>


optional(defaultValue?): FluentSpec<Spec>

Defined in: extract/spec.ts:277

unknown

FluentSpec<Spec>


or<U>(…fallbacks): FluentSpec<TrySpec<T | U>>

Defined in: extract/spec.ts:267

U extends Spec

…(U | FluentSpec<U>)[]

FluentSpec<TrySpec<T | U>>