# filterItems

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

Creates a filter items transformation action.

```ts
const Action = v.filterItems<TInput>(operation);
```

## Generics

- `TInput` `extends ArrayInput`

## Parameters

- `operation` `ArrayRequirement<TInput>`

### Explanation

With `filterItems` you can filter the items of an array. Returning `true` for an item will keep it in the array and returning `false` will remove it.

## Returns

- `Action` `FilterItemsAction<TInput>`

## Examples

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

### Filter duplicate items

Schema to filter duplicate items from an array.

```ts
const FilteredArraySchema = v.pipe(
  v.array(v.string()),
  v.filterItems((item, index, array) => array.indexOf(item) === index)
);
```

## Related

The following APIs can be combined with `filterItems`.

### Schemas

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

### Methods

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

### Utils

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