Skip to content

time

Validates durations in TheTime format. DDataParser.time() ensures the input is a TheTime, applies your checkers (min, max, refine, etc.) and returns an Either containing either the validated value or a DataParserError.

Interactive example

Parameters

  • errorMessage: custom message when the input is not a TheTime.
  • checkers: checkerTimeMin, checkerTimeMax, checkerRefine, etc.
  • coerce: true to accept a number (ms) or an ISO string (HH:MM[:SS[.mmm]]) before converting to TheTime. Defaults to false.

Return value

A DataParserTime with parse, asyncParse, exec, asyncExec, addChecker, clone. parse returns DEither.success<TheTime> if everything passes or DEither.error<DataParserError> with the accumulated issues.

Other examples

Custom checkers

Extended mode

See also

  • date - Parser for dates
  • coerce.* - Coercion functions for various types

Released under the MIT license.