Skip to content

tuple

DDataParser.tuple() describes a positional array with different parsers per index and, optionally, a rest. Perfect to model multi-value returns or fixed parameters.

Interactive example

Parameters

  • shape: array of parsers [DP.string(), DP.number(), ...].
  • rest: optional parser applied to extra elements.
  • checkers: checkerArrayMin, checkerArrayMax, checkerRefine to validate the overall shape.

Return value

A DataParserTuple. schema.parse(data) returns DEither.success<[...]> if all elements satisfy their parser, otherwise DEither.error<DataParserError> with the incriminated index.

See also

Released under the MIT license.