Skip to content

date

DDataParser.date() validates immutable TheDate values. It natively accepts TheDate, SerializedTheDate, and JavaScript Date. In coercive mode (coerce: true), it also accepts safe timestamps and parsable date strings.

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 also accept number (safe timestamp) and string (parsable date) and 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

  • time - Parser for TheTime durations
  • nil - Parser for null/undefined values
  • empty - Parser for empty values

Released under the MIT license.