> 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/other-common-api/enum.md).

# format

format(callback, \[ctx])

## 作用

对`validate`和`validateSilent`的最终返回结果做格式化操作。`callback`的返回值将作为默认返回值。

## 参数

* `callback` ***(function)***  - 格式化回调函数，*该函数有一个参数：`validate`格式化前的返回值*。该函数建议但不必须返回`schema`所声明的类型。
* `[ctx]` ***(\*)***  - `callback`执行的上下文`this`.

## 示例

```javascript
const schema = racoon.number();
schema.validate(1.2).format(num => num.toFixed(2)); // pass, 返回 '1.20'
```
