Skip to content

Commit

Permalink
Add rule object(message?: string)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwh1990 committed May 28, 2019
1 parent 2a7517f commit 4955630
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ FormRules.withName('字段').callback((value, field) => {
#### withoutWhiteSpace(message?: string)
禁止包含空格

#### object(message?: string)
数据必须是对象。如时间控件返回的是moment的对象

#### append(obj)
如果以上规则都不能满足你,那么可以用这个append直接添加antd的原生规则。或者欢迎issue
```javascript
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antd-form-rules",
"version": "1.2.1",
"version": "1.3.0",
"main": "index.js",
"types": "index.d.ts",
"repository": "[email protected]:fwh1990/antd-form-rules.git",
Expand Down
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ export class FormRules {
return this.match(/^[^\s]+$/, message);
}

public object(message: string = ':name必须是对象类型'): FormRules {
this.rules.push({
type: FormRuleType.object,
message: message.replace(':name', this.name),
});

return this;
}

public resetRule(): FormRules {
this.rules = [];

Expand Down

0 comments on commit 4955630

Please sign in to comment.