Files
vitfit-r2/V2/app/core/schemas/clients.js
T
2026-06-13 08:03:45 -04:00

55 lines
1.7 KiB
JavaScript

'use strict';
const { z } = require('zod');
const createClient = z.object({
username: z.string().min(1).max(64).regex(/^[a-zA-Z0-9_.-]+$/),
firstName: z.string().max(100).optional(),
lastName: z.string().max(100).optional(),
email: z.string().email().optional(),
password: z.string().min(8).max(128),
coachId: z.number().int().positive().optional(),
});
const assignCoach = z.object({
coachId: z.number().int().positive(),
});
const workoutItem = z.discriminatedUnion('type', [
z.object({
type: z.literal('video'),
videoId: z.number().int().positive(),
reps: z.number().int().min(0).optional(),
sets: z.number().int().min(0).optional(),
notes: z.string().max(500).optional(),
}),
z.object({
type: z.literal('text'),
text: z.string().min(1).max(1000),
}),
]);
const createClientWorkout = z.object({
name: z.string().min(1).max(200),
scheduledDate: z.string().datetime().optional(),
notes: z.string().max(2000).optional(),
items: z.array(workoutItem).min(1).max(100),
});
const updateClientWorkout = createClientWorkout.partial();
const createSession = z.object({
title: z.string().min(1).max(200),
sessionType: z.enum(['personal', 'group', 'assessment', 'other']).default('personal'),
startAt: z.string().datetime(),
endAt: z.string().datetime(),
locationNotes: z.string().max(500).optional(),
coachNotes: z.string().max(2000).optional(),
sharedNotes: z.string().max(2000).optional(),
linkedWorkoutId: z.number().int().positive().optional(),
});
const updateSession = createSession.partial();
module.exports = { createClient, assignCoach, createClientWorkout, updateClientWorkout, createSession, updateSession };