isValidFiscalPattern
Signature
Section titled “Signature”isValidFiscalPattern(pattern: unknown): pattern is FiscalPatternReturn true when pattern is a valid FiscalPattern.
- Valid patterns are: “4-5-4” (the NRF retail calendar), “4-4-5”, “5-4-4”.
- Accepts any input type and returns false for non-string values.
- Uses type assertion to narrow the type.
getFiscalPeriodreturns null for a pattern it does not recognise — the same sentinel it returns for a date it cannot place. Check the pattern here to tell a misconfigured calendar apart from an unusable date: a pattern read from config, an env var or a form is a bare string until something narrows it.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pattern | unknown | candidate value of any type |
Returns
Section titled “Returns”boolean indicating validity
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidFiscalPattern } from "@northguild/gmt/calendar/validate";
isValidFiscalPattern("4-5-4") // true (the NRF retail calendar)