Skip to content

templateLiteral

Builds a parser for a deterministic string shape ("order-${number}", "user-${string}-${number}", etc.). DDataParser.templateLiteral() takes an array mixing primitive parts and sub-parsers (string, number, literal, ...) and returns a strongly typed string parser.

Interactive example

Parameters

  • template: shape to validate (primitive parts or compatible sub-parsers).
  • pattern: RegExp automatically generated from the template (override rarely needed).
  • checkers: checkerRefine to apply additional rules.

Return value

A DataParserTemplateLiteral that produces a string matching the provided template. parseDEither.success<string> or DEither.error<DataParserError>.

Other examples

Custom checkers

Extended mode

See also

  • bigint - Parser for large integers
  • boolean - Parser for boolean values

Released under the MIT license.