Skip to content
This repository was archived by the owner on Nov 26, 2021. It is now read-only.

Commit 605b2bd

Browse files
committed
fix removeSchemas to return this
1 parent ca50eae commit 605b2bd

8 files changed

Lines changed: 31 additions & 62 deletions

File tree

README-zh_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ return (
170170
| addValues | function | this | true | 添加一个或多个值 |
171171
| removeValues | function | this | true | 删除一个或多个值 |
172172
| addSchemas | function | this | false | 添加一个或多个验证规则 |
173-
| removeSchemas | function | Promise => this | true | 删除一个或多个验证规则 |
173+
| removeSchemas | function | this | true | 删除一个或多个验证规则 |
174174
| formDidChange | function | | | 回调函数 |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ return (
160160
| addValues | function | this | true | Add one or more value |
161161
| removeValues | function | this | true | Remove one or more value |
162162
| addSchemas | function | this | false | Add one or more validation rules |
163-
| removeSchemas | function | Promise => this | true | Remove one or more validation rules |
163+
| removeSchemas | function | this | true | Remove one or more validation rules |
164164
| formDidChange | function | | | Callback |
165165

166166
You can either pass in `values` as an argument, or call the `init` method when the form is initialized.

example/ChildForm.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class ChildForm extends Component {
3737
});
3838
};
3939

40-
handleDeleteFriend = async () => {
40+
handleDeleteFriend = () => {
4141
const { formControl } = this.props;
42-
(await formControl.removeSchemas('friend')).removeValues('friend');
42+
formControl.removeSchemas('friend').removeValues('friend');
4343
};
4444

4545
render() {

lib/FormControl.js

Lines changed: 21 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/FormControl.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-validate-framework",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "React validation framework.",
55
"main": "lib/index.js",
66
"scripts": {

src/FormControl.jsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,12 @@ export default (schemas, methods) => FormComponent => (
338338
* Delete one or more validation rules
339339
* @param names
340340
*/
341-
removeSchemas = async (...names) => {
342-
const { fields } = this.state;
341+
removeSchemas = (...names) => {
343342
names.forEach((name) => {
344343
delete this.schemas[name];
345344
});
346345
// Validate the deleted status
347-
await this.validateFieldsByNames(...names);
348-
// Update
349-
this.setState({
350-
fields,
351-
});
346+
this.validateByNames(...names);
352347
return this;
353348
};
354349

test/setup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ describe('Test nested forms', () => {
175175
expect(app.node.formValues.birthday).to.equal('2010-10-10');
176176
expect(app.node.isAllValid).to.equal(false);
177177
// removeSchemas
178-
await app.node.removeSchemas('phone');
178+
app.node.removeSchemas('phone');
179+
await sleep(5);
179180
expect(app.node.isAllValid).to.equal(true);
180181
});
181182

0 commit comments

Comments
 (0)