Gift Card Validation Schemas (schemas/gift-card.ts)

spree · packages/dashboard/src/schemas/gift-card.ts · typescript · BSD-3-Clause
payments, ui, lang:typescript, fw:zod, tag:validation

Zod validation schemas and parameter conversion utilities for Spree gift card creation and editing forms. Reuse when building e-commerce admin interfaces.

// Source: https://github.com/spree/spree | License: BSD-3-Clause | Copyright 2024-present, Vendo Sp. z o.o., Vendo Connect Inc
// Provided via justclaw.it.com; keep this notice with the code.
import type {
  GiftCardBatchCreateParams,
  GiftCardCreateParams,
  GiftCardUpdateParams,
} from '@spree/admin-sdk'
import {
  blankToNull,
  blankToUndefined,
  currencyCodeSchema,
  i18n,
  isPositiveMoney,
} from '@spree/dashboard-core'
import { z } from 'zod/v4'

// Mirrors `Spree::Config[:gift_card_batch_limit]`. Hardcoded for now; if the
// merchant overrides it we'll surface it via a store-settings endpoint later.
export const BATCH_LIMIT = 50_000

// Zod accepts a message function for lazy evaluation — important so the i18n
// catalog has had a chance to initialize and so locale changes pick

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key