> 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/required.md).

# required

## Effect

Restrict the detected string is not `undefined | null`.

If strict mode is turned o&#x6E;***(strict=true)***, the detected string can not be `undefined | null | ''`.

## Arguments

* `[strict]` ***(boolean)*** - Whether turn on strict mode, default is `false`, means no-strict mode. You can exactly set `strict` to `true` to turn on strict mode.

## Example

```javascript
const schema1 = racoon.string();
schema1.validate(undefined); // pass, return: undefined
schema1.validate(null); // pass, return: null
schema1.validate(''); // pass, return: ''

const schema2 = racoon.string().required();
schema2.validate(undefined); // fail
schema2.validate(null); // fail
schema2.validate(''); // pass

const schema3 = racoon.string().required(true);
schema3.validate(undefined); // fail
schema3.validate(null); // fail
schema3.validate(''); // fail
```
