isValidDateUnit
Signature
Section titled “Signature”isValidDateUnit(unit: unknown): unit is DateUnitReturn 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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
unit | unknown | candidate value of any type |
Returns
Section titled “Returns”boolean indicating validity
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidDateUnit } from "@northguild/gmt/plain/validate";
isValidDateUnit("year") // true