# request.invalid

A field breaks a rule: too long, the wrong format, out of range

Profile: [Errors](https://www.prongs.dev/docs/intents/errors.md) · Raised with: [`fail()`](https://www.prongs.dev/docs/profiles/errors.md) · Status: `422` · Message: yours

## Example

```ts
return fail('request.invalid', 'Use 1–32 lowercase letters, numbers, or hyphens.');
```

The caller gets

```bash
HTTP 422

{
  "ok": false,
  "error": "Use 1–32 lowercase letters, numbers, or hyphens.",
  "code": "request.invalid"
}
```

## Choosing between neighbours

Find the row that describes your case, and use the intent on the right.

| If it is for… | Use |
|---|---|
| A field breaks a rule: too long, the wrong format, out of range | `request.invalid` (this page) |
| A value that is fine on its own but clashes with existing data, like a taken handle | [`conflict.duplicate`](https://www.prongs.dev/docs/intents/conflict/duplicate.md) |
| A readable request with a wrong value (rather than [`request.malformed`](https://www.prongs.dev/docs/intents/request/malformed.md)) | `request.invalid` (this page) |
| Anything the caller did wrong (rather than [`failure.internal`](https://www.prongs.dev/docs/intents/failure/internal.md)) | `request.invalid` (this page) |

## Connections

Declared in the registry, both directions. Where an intent is used in your own code is something check and the gallery see; this site has no app code.

- Built from: [`status.unprocessable`](https://www.prongs.dev/docs/intents/errors.md#status-unprocessable)

## For registry authors

**Starter intents.** These are the intents `prongs add errors` puts in your registry, raised with [`fail()`](https://www.prongs.dev/docs/profiles/errors.md). Change the messages to suit your app, and the statuses through the [`status.*`](https://www.prongs.dev/docs/intents/errors.md#status) intents they are built from.

The entry `prongs add errors` writes into your registry. Change the message here, or the status through its [`status.*`](https://www.prongs.dev/docs/intents/errors.md#status) ref.

```ts
'request.invalid': {
  kind: 'semantic',
  description: 'A field breaks a rule: too long, the wrong format, out of range',
  refs: ['status.unprocessable'],
  keywords: ['validation', 'invalid', 'too long', 'format'],
  notFor: [
    {
      context: 'a value that is fine on its own but clashes with existing data, like a taken handle',
      instead: 'conflict.duplicate',
    },
  ],
  binding: { publicMessage: 'Check what you entered.' },
},
```
