# default

## 作用

设置当被检测值为`undefined | null | NaN`时，`validate`和`validateSilent`方法的返回值。

若开启严格模&#x5F0F;***(strict=true)***, 则设置被检测值为`undefined | null | NaN | '' | {} | []`时的默认返回值。

## 参数

* `value` ***(\*)***  - *`validate`*&#x548C;*`valdiateSilent`*&#x9ED8;认值，可为任意类型。当`value`为函数时，则设置函数的返回值为默认值，函数参数为被检测值原始值——`undefined`, `null`, `NaN`, `''`, `{}`或`[]`.
* `[strict]` ***(boolean)*** - 是否为严格模式，默认为`false`不开启。若明确设置`strict=true`则开启严格模式。
* `[ctx]` ***(\*)*** - 当`value`为函数时的执行上下文`this`。

## 示例

```javascript
const schema1 = racoon.any().default(1);
schema1.validate(undefined); // pass, 返回 1
schema1.validate(null); // pass, 返回 1
schema1.validate(NaN); // pass, 返回 1

const schema2 = racoon.any().default(1, true);
schema2.validate(undefined); // pass, 返回 1
schema2.validate(null); // pass, 返回 1
schema2.validate(NaN); // pass, 返回 1
schema2.validate(''); // pass, 返回 1
schema2.validate({}); // pass, 返回 1
schema2.validate([]); // pass, 返回 1
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://racoon-js.gitbook.io/zh/jie-kou-shuo-ming/any/default.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
