Skip to content

date

DDataParser.date() validates a TheDate (proprietary format date${number}${"-" | "+"}), accepts Date, timestamps, or existing TheDate as input, and returns an immutable safe value across your services.

Interactive example

Parameters

  • errorMessage: custom message if the input cannot be converted to TheDate.
  • checkers: checkerRefine to express your rules (ranges, intervals, etc.).
  • coerce: true to accept Date, number, or ISO string then convert to TheDate. Defaults to false.

Return value

A DataParserDate with the usual API (parse, asyncParse, exec, asyncExec, addChecker, clone). parse returns DEither.success<TheDate> or DEither.error<DataParserError> containing the issues.

Other examples

Custom checkers

Extended mode

See also

  • nil - Parser for null/undefined values
  • empty - Parser for empty values

Released under the MIT license.