All files / lib/validations testimonial.ts

100% Statements 34/34
100% Branches 0/0
100% Functions 0/0
100% Lines 34/34

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 521x         1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x         1x         1x 1x 1x 1x 1x 1x 1x            
import { z } from 'zod';
 
/**
 * Create testimonial schema
 */
export const createTestimonialSchema = z.object({
  author_name: z
    .string()
    .min(2, 'Author name must be at least 2 characters')
    .max(100, 'Author name must be at most 100 characters'),
  author_title: z
    .string()
    .max(100, 'Author title must be at most 100 characters')
    .optional()
    .nullable(),
  author_avatar_url: z.string().url('Please enter a valid avatar URL').optional().nullable(),
  content: z
    .string()
    .min(10, 'Testimonial must be at least 10 characters')
    .max(1000, 'Testimonial must be at most 1000 characters'),
  source: z.string().max(50, 'Source must be at most 50 characters').optional().nullable(),
  rating: z
    .number()
    .int()
    .min(1, 'Rating must be at least 1')
    .max(5, 'Rating must be at most 5')
    .optional()
    .nullable(),
  display_order: z.number().int().min(0).default(0),
});
 
/**
 * Update testimonial schema (partial)
 */
export const updateTestimonialSchema = createTestimonialSchema.partial();
 
/**
 * Testimonial with ID (for responses)
 */
export const testimonialSchema = createTestimonialSchema.extend({
  id: z.string().uuid(),
  profile_id: z.string().uuid(),
  is_verified: z.boolean().default(false),
  created_at: z.string().datetime(),
  updated_at: z.string().datetime(),
});
 
// Type exports
export type CreateTestimonialInput = z.infer<typeof createTestimonialSchema>;
export type UpdateTestimonialInput = z.infer<typeof updateTestimonialSchema>;
export type Testimonial = z.infer<typeof testimonialSchema>;