> For the complete documentation index, see [llms.txt](https://racoon-js.gitbook.io/zh/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/zh/jie-kou-shuo-ming/boolean/required.md).

# required

required()

## 作用

限制被检测值不为`undefined | null`.

## 参数

无

## 示例

```javascript
const schema1 = racoon.boolean();
schema1.validate(undefined); // pass, 返回值为 undefined
schema1.validate(null); // pass, 返回值为 null

const schema2 = racoon.boolean().required();
schema2.validate(undefined); // fail
schema2.validate(null); // fail
schema2.validate(false); // pass
```
