Skip to content

@xtandard/lib/valibot

Branded TimeZone, duration and Temporal schemas for valibot (peers valibot, @js-temporal/polyfill).

import { … } from "@xtandard/lib/valibot";
Name Summary
parseTimeZone Parse an unknown value as a TimeZone, throwing when it isn’t a valid IANA id. Shorthand for v.parse(TimeZoneSchema, input).
Name Summary
DurationSchema valibot schema for an ISO-8601 duration (PT30M, P1DT2H). Validated with Temporal.Duration.from and normalized to the canonical string. Output is a string, not a Temporal.Duration.
InstantSchema valibot schema for an ISO-8601 instant with an offset or Z (2026-06-18T16:00:00Z). Validated with Temporal.Instant.from and normalized to UTC Z form. Output is a string, not a Temporal.Instant.
PlainDateSchema valibot schema for a calendar date YYYY-MM-DD. Validated with Temporal.PlainDate.from (so impossible dates fail) and normalized to the canonical string. Output is a string, not a Temporal.PlainDate.
PlainDateTimeSchema valibot schema for a floating wall date+time YYYY-MM-DDTHH:MM[:SS] (no zone). Validated with Temporal.PlainDateTime.from and normalized to the canonical string. Output is a string, not a Temporal.PlainDateTime.
PlainTimeSchema valibot schema for a wall-clock time HH:MM[:SS]. Validated with Temporal.PlainTime.from and normalized to the canonical string (seconds always present). Output is a string, not a Temporal.PlainTime.
TimeZoneSchema valibot schema: validate an IANA id and brand it as TimeZone. Fails with the issue message "Invalid IANA time zone". The value is not canonicalized.
ZonedDateTimeSchema valibot schema for a zoned date-time with a bracketed IANA zone (2026-06-18T09:00-07:00[America/Los_Angeles]). Validated with Temporal.ZonedDateTime.from and normalized to the canonical string (the offset is filled in). Output is a string, not a Temporal.ZonedDateTime.