Skip to content

TimeZoneSchema

const TimeZoneSchema: SchemaWithPipe<readonly [StringSchema<undefined>, CheckAction<string, "Invalid IANA time zone">, TransformAction<string, TimeZone>]>;

Defined in: valibot-utils.ts:21

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.

import * as v from "valibot";
import { TimeZoneSchema } from "@xtandard/lib/valibot";
const SettingsSchema = v.object({ timeZone: TimeZoneSchema });
v.parse(SettingsSchema, { timeZone: "America/New_York" }); // { timeZone: "America/New_York" }
v.safeParse(TimeZoneSchema, "Mars/Olympus").issues?.[0].message; // "Invalid IANA time zone"