transactionTypeEnum (schemas/transaction.schema.ts)

WealthWise-Finance-Tracker · packages/shared-types/src/schemas/transaction.schema.ts · typescript · MIT
database, tag:embed-classified

Zod schemas for creating, updating, querying, and responding to financial transactions.

// Source: https://github.com/hoangsonww/WealthWise-Finance-Tracker | License: MIT | Copyright 2026 Son Nguyen
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from "zod";

/**
 * Transaction type: money coming in, going out, or moving between accounts.
 */
export const transactionTypeEnum = z.enum(["income", "expense", "transfer"]);

/**
 * Allowed sort fields for transaction queries.
 */
export const transactionSortByEnum = z.enum(["date", "amount", "description", "createdAt"]);

/**
 * Sort direction.
 */
export const sortOrderEnum = z.enum(["asc", "desc"]);

/**
 * ISO date string validator (YYYY-MM-DD or full ISO 8601 datetime).
 */
const isoDateString = z.string().refine(
  (val) => {
    const date = new Date(val);
    return !isNaN(date.getTime());
  },

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

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

Get a free API key