mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { z } from 'zod';
|
|
import { nameSchema } from '@/schemas/common';
|
|
|
|
type TFunction = (key: string) => string;
|
|
|
|
/**
|
|
* Contact schema with internationalized error messages
|
|
* Uses Zod v4's improved error handling and common base schemas
|
|
*/
|
|
export const getContactSchema = (t: TFunction) =>
|
|
z.object({
|
|
name: nameSchema.min(1, { message: t('validation.contact.name_min') }),
|
|
role: z.string().optional().describe('Contact role or title'),
|
|
email: z
|
|
.string()
|
|
.email({ message: t('validation.contact.email') })
|
|
.or(z.literal(''))
|
|
.optional()
|
|
.describe('Email address (can be empty)'),
|
|
phone: z
|
|
.string()
|
|
.regex(/^((\+7|7|8)+([0-9()\-\s]){10,15})?$/, { message: t('validation.contact.phone') })
|
|
.or(z.literal(''))
|
|
.optional()
|
|
.describe('Phone number (Russian format, can be empty)'),
|
|
});
|
|
|
|
/**
|
|
* Base contact schema for data consistency
|
|
* Uses Zod v4's composition with common schemas for DRY code
|
|
*/
|
|
export const contactSchema = z.object({
|
|
name: nameSchema.min(1, { message: 'Name is required.' }),
|
|
role: z.string().optional().describe('Contact role or title'),
|
|
email: z
|
|
.string()
|
|
.email({ message: 'Please enter a valid email address.' })
|
|
.or(z.literal(''))
|
|
.optional()
|
|
.describe('Email address (can be empty)'),
|
|
phone: z
|
|
.string()
|
|
.regex(/^((\+7|7|8)+([0-9()\-\s]){10,15})?$/, { message: 'Please enter a valid phone number.' })
|
|
.or(z.literal(''))
|
|
.optional()
|
|
.describe('Phone number (Russian format, can be empty)'),
|
|
});
|