# allowString

## 作用

允许被检测值为数值的字符串表现形式。

> **说明**
>
> 符合正则表达式`/^[+-]?\d.?\d$/`的字符串即为数值的字符串形式，比如 '123', '-123', '.123', '0.123'.

## 可用版本

\>=1.3.0

## 参数

无

## 示例

```javascript
const schema1 = racoon.number();
schema.validate('123'); // fail

const schema2 = racoon.number().allowString();
schema.validate('123'); // pass, 返回数值 123
schema.validate('.123'); // pass, 返回数值 0.123
schema.validate('-123'); // pass, 返回数值 -123
schema.validate('+123'); // pass, 返回数值 123
```


---

# 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/number/allowstring.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.
