Skip to content

Commit

Permalink
feat: replace async-validator to @rc-component/async-validator (#679)
Browse files Browse the repository at this point in the history
* feat: replace async-validator to @rc-component/async-validator

* feat: doc
  • Loading branch information
crazyair committed Apr 16, 2024
1 parent b576957 commit b26d048
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open http://localhost:8000
## Feature

- Support react.js and even react-native
- Validate fields with [async-validator](https://github.com/yiminghe/async-validator/)
- Validate fields with [@rc-component/async-validator](https://github.com/react-component/async-validator/)

## Install

Expand All @@ -35,13 +35,13 @@ open http://localhost:8000
```js | pure
import Form, { Field } from 'rc-field-form';

const Input = ({ value = "", ...props }) => <input value={value} {...props} />;
const Input = ({ value = '', ...props }) => <input value={value} {...props} />;

const Demo = () => {
return (
<Form
onFinish={(values) => {
console.log("Finish:", values);
onFinish={values => {
console.log('Finish:', values);
}}
>
<Field name="username">
Expand Down Expand Up @@ -81,20 +81,20 @@ We use typescript to create the Type definition. You can view directly in IDE. B

### Field

| Prop | Description | Type | Default |
| ----------------- | ----------------------------------------------------------------------------- | ------------------------------------------- | -------- |
| dependencies | Will re-render if dependencies changed | [NamePath](#namepath)[] | - |
| getValueFromEvent | Specify how to get value from event | (..args: any[]) => any | - |
| getValueProps | Customize additional props with value. This prop will disable `valuePropName` | (value) => any | - |
| initialValue | Field initial value | any | - |
| name | Field name path | [NamePath](#namepath) | - |
| normalize | Normalize value before update | (value, prevValue, prevValues) => any | - |
| preserve | Preserve value when field removed | boolean | false |
| rules | Validate rules | [Rule](#rule)[] | - |
| Prop | Description | Type | Default |
| ----------------- | ----------------------------------------------------------------------------- | ---------------------------------------------- | -------- |
| dependencies | Will re-render if dependencies changed | [NamePath](#namepath)[] | - |
| getValueFromEvent | Specify how to get value from event | (..args: any[]) => any | - |
| getValueProps | Customize additional props with value. This prop will disable `valuePropName` | (value) => any | - |
| initialValue | Field initial value | any | - |
| name | Field name path | [NamePath](#namepath) | - |
| normalize | Normalize value before update | (value, prevValue, prevValues) => any | - |
| preserve | Preserve value when field removed | boolean | false |
| rules | Validate rules | [Rule](#rule)[] | - |
| shouldUpdate | Check if Field should update | boolean \| (prevValues, nextValues) => boolean | - |
| trigger | Collect value update by event trigger | string | onChange |
| validateTrigger | Config trigger point with rule validate | string \| string[] | onChange |
| valuePropName | Config value mapping prop with element | string | value |
| trigger | Collect value update by event trigger | string | onChange |
| validateTrigger | Config trigger point with rule validate | string \| string[] | onChange |
| valuePropName | Config value mapping prop with element | string | value |

### List

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"dependencies": {
"@babel/runtime": "^7.18.0",
"async-validator": "^4.1.0",
"@rc-component/async-validator": "^5.0.1",
"rc-util": "^5.32.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validateUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import RawAsyncValidator from 'async-validator';
import RawAsyncValidator from '@rc-component/async-validator';
import * as React from 'react';
import warning from 'rc-util/lib/warning';
import type {
Expand Down

0 comments on commit b26d048

Please sign in to comment.