Skip to content

transform

DDataParser.transform(inner, fn) applies a parser, then transforms the validated value (synchronously or asynchronously) before returning it. Ideal to create business objects (URL, Date, DTOs) without a manual pipe.

Interactive example

Parameters

  • inner: starting parser (string, object, etc.).
  • theFunction(value, error): transformation function (can use error to signal a custom error by returning SymbolDataParserError).
  • checkers: checkerRefine applied on the transformed result.
  • errorMessage: generic message if the pipeline fails.

Return value

A DataParserTransform. schema.parse(data) validates the input with inner, executes theFunction, and returns the new value via DEither.success. If any stage fails, you receive DEither.error<DataParserError> with the full trace.

Other examples

Extended mode

See also

  • record - Parser for key/value dictionaries
  • recover - Lets you recover from an error by providing a fallback value

Released under the MIT license.