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

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

# maxGraphemes

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

```ts
const Action = v.maxGraphemes<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 `maxGraphemes` 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` for maximum length checks, use <Link href="../maxLength/">`maxLength`</Link> instead.

> Hint: The number of characters per grapheme is not limited. You may want to consider combining `maxGraphemes` with <Link href="../maxLength/">`maxLength`</Link> or <Link href="../maxBytes/">`maxBytes`</Link> to set a stricter limit.

## Returns

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

## Examples

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

### Max graphemes schema

Schema to validate a string with a maximum of 8 graphemes.

```ts
const MaxGraphemesSchema = v.pipe(
  v.string(),
  v.maxGraphemes(8, 'The string must not exceed 8 graphemes.')
);
```

## Related

The following APIs can be combined with `maxGraphemes`.

### Schemas

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

### Methods

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

### Actions

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

### Utils

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