# Register

> User registration with strong password policy and confirmation matching.

- Name: `register`
- Categories: auth
- Detail page: https://open-types.dev/types/register

## Install

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

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

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

## Types

```typescript
export interface Register {
  email: string;
  password: string;
  confirmPassword: string;
  name: string;
  tosAccepted: true;
}
```

## Zod validator

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

const STRONG_PASSWORD_REGEX =
  /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,128}$/;

export const registerSchema = z
  .object({
    email: z.email({ error: "Invalid email address" }),
    password: z
      .string()
      .min(8, { error: "Password must be at least 8 characters" })
      .max(128, { error: "Password must be at most 128 characters" })
      .regex(STRONG_PASSWORD_REGEX, {
        error:
          "Password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character",
      }),
    confirmPassword: z.string(),
    name: z.string().min(1, { error: "Name is required" }),
    tosAccepted: z.literal(true, {
      error: "You must accept the Terms of Service",
    }),
  })
  .refine((data) => data.password === data.confirmPassword, {
    error: "Passwords do not match",
    path: ["confirmPassword"],
  }) satisfies z.ZodType<Register>;

export type { Register } from "../types/register";
```

## Examples

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

export const registerExamples = {
  jenny: {
    email: "jenny@example.com",
    password: "Str0ng!Pass-word",
    confirmPassword: "Str0ng!Pass-word",
    name: "Jenny Rosen",
    tosAccepted: true,
  } satisfies Register,
  alex: {
    email: "alex.patel@example.com",
    password: "C0mplex#PWord-2026",
    confirmPassword: "C0mplex#PWord-2026",
    name: "Alex Patel",
    tosAccepted: true,
  } satisfies Register,
  longName: {
    email: "name@example.com",
    password: "An0ther$Strong-One",
    confirmPassword: "An0ther$Strong-One",
    name: "María José García-Martínez de la Vega",
    tosAccepted: true,
  } satisfies Register,
} as const;
```
