Skip to content

parseBool

parseBool<T>(spec, options?): MapSpec<T>

Defined in: extract/spec.ts:904

Parse a string value into a boolean.

Default truthy values: "true", "1", "yes", "y", "on". Default falsy values: "false", "0", "no", "n", "off". Custom truthy/falsy values are added to the defaults.

Produces schemaHint: { type: 'boolean' } for schema derivation.

T extends Spec

T

BoolParseOptions

MapSpec<T>

// Default truthy/falsy
parseBool($.get('active').string())
// Custom truthy/falsy
parseBool($.get('status').string(), { truthy: ['active'], falsy: ['inactive'] })