Skip to content

isValidDate

isValidDate(value: string): boolean

Return true if value is a valid ISO PlainDate string.

  • The part before the first annotation must match plainDate (a date, not a date-time).
  • Reads RFC 9557 annotations as Temporal.PlainDate.from does: elective ones ([foo=bar]) and a time zone annotation are ignored, and an unknown critical one ([!foo=bar]) is rejected. The calendar must be ISO ([u-ca=iso8601] is accepted); a non-ISO calendar is isValidCalendarDate’s input.
  • Rejects leap seconds (e.g., “2024-12-31T23:59:60”).
  • Rejects invalid dates (e.g., “2024-02-30”).
ParameterTypeDescription
valuestringISO PlainDate string

boolean indicating validity

import { isValidDate } from "@northguild/gmt/plain/validate";
isValidDate("2024-03-10") // true
output 

plain/validate/isValidDate.ts