Skip to content

boolean

Builds a parser for booleans. DDataParser.boolean() checks the input, supports coercion ("true", 1, etc.), and allows custom checkers via checkerRefine.

Interactive example

Parameters

  • errorMessage: custom message when the input cannot be interpreted as a boolean.
  • checkers: checkerRefine to add business rules (for example force true).
  • coerce: true to convert "true", "false", 1, 0, etc. Defaults to false.

Return value

A DataParserBoolean with parse, asyncParse, exec, asyncExec, addChecker, clone. schema.parse(data) returns DEither.success<boolean> or DEither.error<DataParserError>.

Other examples

Custom checkers

Extended mode

See also

  • string - Parser for strings
  • coerce.* - Coercion functions for various types

Released under the MIT license.