API: adres strukturalny w endpoints /gyms (REAL wymaga ulicy/kodu/miasta, location derivowane, merge przy PATCH)
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
import { z } from 'zod';
|
||||
import { availabilitySchema } from '../me.js';
|
||||
|
||||
// Adres strukturalny (wzorzec Google/UPU); wymóg kompletności dla REAL egzekwuje serwis.
|
||||
export const gymAddressFields = {
|
||||
addressLine1: z.string().trim().min(1).max(200).nullable().optional(),
|
||||
addressLine2: z.string().trim().max(200).nullable().optional(),
|
||||
postalCode: z
|
||||
.string()
|
||||
.trim()
|
||||
.regex(/^\d{2}-\d{3}$/, 'Format kodu pocztowego: 00-001')
|
||||
.nullable()
|
||||
.optional(),
|
||||
city: z.string().trim().min(1).max(100).nullable().optional(),
|
||||
countryCode: z.string().trim().regex(/^[a-zA-Z]{2}$/).nullable().optional(),
|
||||
};
|
||||
|
||||
export const createGymSchema = z.object({
|
||||
name: z.string().min(1).max(200),
|
||||
location: z.string().max(500).nullable().optional(),
|
||||
...gymAddressFields,
|
||||
availability: availabilitySchema,
|
||||
capacity: z.number().int().positive().max(100000).nullable().optional(),
|
||||
kind: z.enum(['VIRTUAL', 'REAL']).optional(),
|
||||
|
||||
Reference in New Issue
Block a user