# max

## 作用

限制被检测字符串长度的最大值。

## 参数

* `limit`***(number)*** 长度的最大值
* `[closed]`***(boolean)*** 是否闭区间，默认`true`, 表示闭区间，被检测字符串长度需小于或等于`limit`. 若`closed`明确为`false`, 则表示开区间，被检测字符串长度必须严格小于`limit`.

## 示例

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