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 compatible sub-parsers without their own checkers (string, number, literal, ...) and returns a strongly typed string parser.

Interactive example

Parameters

  • template: shape to validate (primitive parts or compatible sub-parsers without their own checkers).
  • pattern: RegExp automatically generated from the template (manual configuration is rarely needed).
  • checkers: checkerRefine to apply additional rules to the final template literal value.

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.