Skip to content

is

The is() function checks that a string matches the TheDate format (date<timestamp><"-" | "+">). It acts as a type guard.

Interactive example

Syntax

typescript
function is(input: string): input is TheDate

Parameters

  • input: String to validate.

Return value

true if the string follows the TheDate format, otherwise false. When true, TypeScript narrows input to TheDate.

See also

Released under the MIT license.