---
title: includes
description: Creates an includes validation action.
source: /actions/includes/includes.ts
contributors:
  - fabian-hiller
---

import { ApiList, Property } from '~/components';
import { properties } from './properties';

# includes

Creates an includes validation action.

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

## Generics

- `TInput` <Property {...properties.TInput} />
- `TRequirement` <Property {...properties.TRequirement} />
- `TMessage` <Property {...properties.TMessage} />

## Parameters

- `requirement` <Property {...properties.requirement} />
- `message` <Property {...properties.message} />

### 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` <Property {...properties.Action} />

## 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

<ApiList
  items={['any', 'array', 'custom', 'instance', 'string', 'tuple', 'unknown']}
/>

### Methods

<ApiList items={['pipe']} />

### Utils

<ApiList items={['isOfKind', 'isOfType']} />
