Customer Validation Schemas (validators/customer.validators.ts)

openvyapar · packages/backend/src/validators/customer.validators.ts · typescript · Apache-2.0
database, security, crm, integration, fw:zod, tag:validation, tag:backend

Defines Zod schemas for creating and updating customer data, enforcing required fields like name and phone. Used for API input validation.

// Source: https://github.com/vijayg10/openvyapar | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from 'zod';

export const createCustomerSchema = z.object({
  name: z.string().min(1, 'Name is required'),
  phone: z.string().min(1, 'Phone is required'),
  email: z.string().email().nullable().optional(),
  address: z.string().nullable().optional(),
  gstin: z.string().nullable().optional(),
  notes: z.string().nullable().optional(),
});

export const updateCustomerSchema = z.object({
  name: z.string().min(1).optional(),
  phone: z.string().min(1).optional(),
  email: z.string().email().nullable().optional(),
  address: z.string().nullable().optional(),
  gstin: z.stri

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

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

Get a free API key