# password-match-refiner

```bash
npx zod-refiners add password-match-refiner
```

Validates that two fields hold the same value. Built for confirmation
fields — and it reports the error **on the confirmation field**, not on
the original, so your form highlights the field the user actually got
wrong.

## Installs

* `password-match-refiner.ts` — the factory
* `types.ts` — the shared `RefineTuple` type (dependency)

## Signature

```ts
function createPasswordMatchRefiner<T extends Record<string, unknown>>(
  passwordField: keyof T & string,
  confirmField: keyof T & string,
  message?: string, // default: "Passwords don't match"
): RefineTuple<T>;
```

## Usage

```ts
import { z } from "zod";
import { createPasswordMatchRefiner } from "@/lib/refiners/password-match-refiner";

type SettingsForm = {
  password: string;
  confirmPassword: string;
};

const settingsSchema = z
  .object({
    password: z.string().min(8),
    confirmPassword: z.string(),
  })
  .refine(
    ...createPasswordMatchRefiner<SettingsForm>(
      "password",
      "confirmPassword",
      "Your passwords must match",
    ),
  );
```

## Behavior

| Case | Result |
|---|---|
| Values equal | Parses successfully |
| Values differ | Issue at `path: ["confirmPassword"]` with your message |
| Works with | `string`, `number`, or any `===`-comparable values |
