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

# allowString

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
```
