Skip to content

feat: replace async-validator to @rc-component/async-validator #679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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