import z from 'zod';
import { objectId } from '@jig-software/zod-bson';

export const ReadingReport = z.object({
  reportId: objectId(), // ✅ call the function
  generatedAt: z
    .string()
    .refine((date) => !isNaN(Date.parse(date)), {
      message: 'Invalid date format',
    }),
  generatedBy: z.string(),
  readings: z.array(
    z.object({
      sensorId: objectId(), // ✅ call the function here too
      timestamp: z
        .string()
        .refine((date) => !isNaN(Date.parse(date)), {
          message: 'Invalid date format',
        }),
      value: z.number(),
      unit: z.string(),
    }),
  ),
});
