Skip to content

isValidDateUnit

  • The core functions, which every industry uses.
isValidDateUnit(unit: unknown): unit is DateUnit

Return true when unit is a valid DateUnit.

  • Valid units are: “year”, “month”, “week”, “day”.
  • Accepts any input type and returns false for non-string values.
  • Uses type assertion to narrow the type.
ParameterTypeDescription
unitunknowncandidate value of any type

boolean indicating validity

import { isValidDateUnit } from "@northguild/gmt/plain/validate";
isValidDateUnit("year") // true
output 

plain/validate/isValidDateUnit.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.