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

# object

## 作用

获取`object`类型`schema`对象。

## 参数

* `[config]` ***(Object)*** 可不传，声明被检测对象的子属性类型的配置对象。需要注意：
  * 若不传`config`, 或者`config`类型不是 ***Object***, 则表示只要求被检测类型为 ***Object*** 即可，不对属性及其值做要求。
  * `config.prop` ***(Schema)*** 表示`config`的任意可枚举属性值，其类型为`racoon`创建的`schema`对象。若其类型不是`racoon`返回的`schema`对象，则会被忽略。

## 示例

```javascript
const schema1 = racoon.object();
schema1.validate(1); // fail
schema1.validate([1, 2]); // fail
schema1.validate({}); // pass
schema1.validate({ prop: 1 }); // pass

const schema2 = racoon.object({
  name: racoon.string(),
  age: racoon.number()
});
schema2.validate({ name: 123, age: 20 }); // fail
schema2.validate({ name: 'abc', age: 20 }); // pass
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/object.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.
