© 2026 Hedgehog Software, LLC
export const DEFAULT_TIMEZONE = 'America/New_York'; const EmptyToDefault = S.transform(S.String, S.String, { strict: true, decode: str => (str.length === 0 ? DEFAULT_TIMEZONE : str), encode: identity }); export const MyStruct = S.Struct({ timezone: S.optionalWith(EmptyToDefault, { nullable: true, default: () => DEFAULT_TIMEZONE }) // ... });
<missing> | null | undefined | ""
// ... timezone: S.optionalWith(S.String, { emptyAsMissing: true, nullable: true, default: () => DEFAULT_TIMEZONE }) // ...