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

# default

## Effect

Set the default return value of `validate` and `validateSilent`, when the detected value is `undefined | null | NaN`.

## Arguments

* `value` ***(\*)*** - The default return value of `validate` and `validateSilent`. It is recommended but not necessarily to be a number. When `value` is a function, then set the return value of `value` to be the default return value. *The function has a parameter: the original detected value - `undefined`, `null` or `NaN`.*
* `[ctx]` ***(\*) -*** The execution context if `value` is a function.

## Example

```javascript
const schema1 = racoon.number().allowNaN().default(1);
schema1.validate(undefined); // pass, return 1
schema1.validate(null); // pass, return 1
schema1.validate(NaN); // pass, return 1

const schema2 = racoon().number().allowNaN().default((val) => {
  if (val === undefined) {
    return 1;
  }
  if (val === null) {
    return 2;
  }
  return 3; // The val must be NaN in this case.
});
schema2.validate(undefined); // pass, return 1
schema2.validate(null); // pass, return 2
schema2.validate(NaN); // pass, return 3
```
