# Review

> Product review with rating (1-5), title, body, and verified purchase flag.

- Name: `review`
- Categories: ecommerce
- Detail page: https://open-types.dev/types/review

## Install

```bash
# Types only
npx shadcn add @open-types/review

# Types + Zod v4 validators
npx shadcn add @open-types/review-zod

# Types + real-world examples
npx shadcn add @open-types/review-examples
```

## Types

```typescript
export interface Review {
  id: string;
  rating: number;
  title?: string;
  body?: string;
  author: string;
  product_id: string;
  created_at: string;
  verified_purchase: boolean;
}
```

## Zod validator

```typescript
import * as z from "zod";
import type { Review } from "../types/review";

export const reviewSchema = z.object({
  id: z.string().min(1, { error: "Review ID is required" }),
  rating: z.number().int({ error: "Rating must be a whole number" }).min(1, {
    error: "Rating must be at least 1",
  }).max(5, { error: "Rating must be at most 5" }),
  title: z.string().max(200, { error: "Title must be at most 200 characters" }).optional(),
  body: z.string().max(5000, { error: "Body must be at most 5000 characters" }).optional(),
  author: z.string().min(1, { error: "Author is required" }),
  product_id: z.string().min(1, { error: "Product ID is required" }),
  created_at: z.string().min(1, { error: "Created at is required" }),
  verified_purchase: z.boolean(),
}) satisfies z.ZodType<Review>;

export type { Review } from "../types/review";
```

## Examples

```typescript
// Source: hand-crafted
import type { Review } from "../types/review";

const positive = {
  id: "rev_01HABCDEF0123456789ABCDE",
  rating: 5,
  title: "Exactly what I needed",
  body: "Arrived on time and works perfectly. Highly recommended.",
  author: "Jenny R.",
  product_id: "prod_widget_001",
  created_at: "2026-05-16T18:30:00Z",
  verified_purchase: true,
} as const satisfies Review;

export const reviewExamples = {
  fiveStarVerified: positive,
  oneStar: {
    ...positive,
    id: "rev_one_star_002",
    rating: 1,
    title: "Did not work",
    body: "Arrived broken, would not turn on.",
    author: "Alex P.",
    verified_purchase: false,
  } satisfies Review,
  threeStar: {
    ...positive,
    id: "rev_three_star_003",
    rating: 3,
    title: "Mixed feelings",
    body: "Build quality is solid but the docs are confusing.",
    author: "Sam L.",
  } satisfies Review,
  minimal: {
    id: "rev_min_004",
    rating: 4,
    author: "Anonymous",
    product_id: "prod_widget_001",
    created_at: "2026-05-16T18:30:00Z",
    verified_purchase: false,
  } satisfies Review,
  titleOnly: {
    ...positive,
    id: "rev_title_005",
    rating: 5,
    title: "Great!",
    body: undefined,
  } satisfies Review,
} as const;
```
