import { prisma } from "@/lib/db" /** * Validates that a childId exists in the database. * Returns the child record or null. * Use this in API routes to prevent access to non-existent children. */ export async function validateChild(childId: string | null) { if (!childId) return null try { const child = await prisma.child.findUnique({ where: { id: childId }, select: { id: true, name: true, profile: true, familyId: true }, }) return child } catch { return null } }