> For the complete documentation index, see [llms.txt](https://racoon-js.gitbook.io/en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://racoon-js.gitbook.io/en/api/string/max.md).

# max

max(limit, \[closed=true])

## Effect

Restrict the max length of the detected string.

## Arguments

* `limit` ***(number) -*** The max length.
* `[closed]` ***(boolean)*** - Whether it is a closed interval or not, the default is`true`, which means a closed interval, it requires the detected string's length less than or equal to `limit`. If you exactly set `closed` to `false`, you'll get an opened interval, it requires the detected string's length strictly less than `limit`.

## Example

```javascript
const schema = racoon.string().max(3);
schema.validate('abcd'); // fail
schema.validate('abc'); // pass
schema.validate('ab'); // pass

const schema2 = racoon.string().max(3, false);
schema2.validate('abcd'); // fail
schema.validate('abc'); // fail
schema.validate('ab'); // pass
```
