# includes

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

Creates an includes validation action.

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

## Generics

- `TInput` `extends ContentInput`
- `TRequirement` `extends ContentRequirement<ContentInput>`
- `TMessage` `extends ErrorMessage<IncludesIssue<TInput, TRequirement>> | undefined`

## Parameters

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

### Explanation

With `includes` you can validate the content of a string or array. If the input does not match the `requirement`, you can use `message` to customize the error message.

## Returns

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

## Examples

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

### String schema

Schema to validate that a string contains a specific substring.

```ts
const StringSchema = v.pipe(
  v.string(),
  v.includes('foo', 'The string must contain "foo".')
);
```

### Array schema

Schema to validate that an array contains a specific string.

```ts
const ArraySchema = v.pipe(
  v.array(v.string()),
  v.includes('foo', 'The array must contain "foo".')
);
```

## Related

The following APIs can be combined with `includes`.

### Schemas

[`any`](/api/any.md), [`array`](/api/array.md), [`custom`](/api/custom.md), [`instance`](/api/instance.md), [`string`](/api/string.md), [`tuple`](/api/tuple.md), [`unknown`](/api/unknown.md)

### Methods

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

### Utils

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