---
title: graphemes
description: Creates a graphemes validation action.
source: /actions/graphemes/graphemes.ts
contributors:
  - fabian-hiller
  - yslpn
---

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

# graphemes

Creates a [graphemes](https://en.wikipedia.org/wiki/Grapheme) validation action.

```ts
const Action = v.graphemes<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 `graphemes` you can validate the graphemes of a string. If the input does not match the `requirement`, you can use `message` to customize the error message.

> If you are looking for an equivalent of JavaScript's `.length`, use <Link href="../length/">`length`</Link> instead.

## Returns

- `Action` <Property {...properties.Action} />

## Examples

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

### Graphemes schema

Schema to validate a string with 8 graphemes.

```ts
const GraphemesSchema = v.pipe(
  v.string(),
  v.graphemes(8, 'Exactly 8 graphemes are required.')
);
```

## Related

The following APIs can be combined with `graphemes`.

### Schemas

<ApiList items={['any', 'custom', 'string']} />

### Methods

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

### Actions

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

### Utils

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