# endsWith

> This document is the Markdown version of [valibot.dev/api/endsWith/](https://valibot.dev/api/endsWith/). For the complete documentation index, see [llms.txt](https://valibot.dev/llms.txt).

Creates an ends with validation action.

```ts
const Action = v.endsWith<TInput, TRequirement, TMessage>(requirement, message);
```

## Generics

- `TInput` `extends string`
- `TRequirement` `extends string`
- `TMessage` `extends ErrorMessage<EndsWithIssue<TInput, TRequirement>> | undefined`

## Parameters

- `requirement` `TRequirement`
- `message` `TMessage`

### Explanation

With `endsWith` you can validate the end of a string. If the end does not match the `requirement`, you can use `message` to customize the error message.

## Returns

- `Action` `EndsWithAction<TInput, TRequirement, TMessage>`

## Examples

The following examples show how `endsWith` can be used.

### Email schema

Schema to validate an email with a specific domain.

```ts
const EmailSchema = v.pipe(v.string(), v.email(), v.endsWith('@example.com'));
```

## Related

The following APIs can be combined with `endsWith`.

### Schemas

[`any`](/api/any.md), [`custom`](/api/custom.md), [`string`](/api/string.md)

### Methods

[`pipe`](/api/pipe.md)

### Utils

[`isOfKind`](/api/isOfKind.md), [`isOfType`](/api/isOfType.md)
