isValidYearMonth
Signature
Section titled “Signature”isValidYearMonth(value: string): booleanisValidYearMonth(value: void | {} | null | undefined): booleanisValidYearMonth(value: unknown): value is stringReturn true if value is a valid ISO year-month string: YYYY-MM or ±YYYYYY-MM.
- The part before the first annotation must match
plainYearMonth: the extended form only (202610is refused, asisValidDaterefuses20241225), a four-digit year or a sign and six digits, never-000000. - The range is Temporal’s:
-271821-04to+275760-09. - A date such as
2026-10-01is not a year-month: useparseYearMonthFromDate. - Reads RFC 9557 annotations as
Temporal.PlainYearMonth.fromdoes: elective ones ([foo=bar]) and a time zone annotation are ignored, and an unknown critical one ([!foo=bar]) is rejected. - The calendar must be
iso8601, in any case ([u-ca=ISO8601]is accepted); any other calendar is refused. - Rejects a time, a
Zand an offset. - A value that is not a string, a
Stringobject included, returnsfalse. Atrueresult narrows anunknownvalue tostring.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | any value; a string is checked as an ISO year-month |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidYearMonth } from "@northguild/gmt/plain/validate";
isValidYearMonth("2026-10") // trueSource
Section titled “Source”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.