Skip to content

Commit

Permalink
fix(demo): 表单组件正则表达式验证示例与实际说明不符 (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
hevi1991 authored Nov 25, 2023
1 parent dc59705 commit 9ec2eea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-vant/src/components/form/demo/rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default () => {
<Form.Item
name='text1'
label='正则校验'
rules={[{ pattern: /\d{6}/, message: '请输入6位数字' }]}
rules={[{ pattern: /^\d{6}$/, message: '请输入6位数字' }]}
>
<Input placeholder='正则校验' />
</Form.Item>
Expand All @@ -30,7 +30,7 @@ export default () => {
rules={[
{
validator: (_, value) => {
if (/1\d{10}/.test(value)) {
if (/^1\d{10}$/.test(value)) {
return Promise.resolve(true)
}
return Promise.reject(new Error('请输入正确的手机号码'))
Expand All @@ -50,7 +50,7 @@ export default () => {
Toast.loading('验证中...')

setTimeout(() => {
if (/\d{6}/.test(value)) {
if (/^\d{6}$/.test(value)) {
resolve(true)
} else {
reject(new Error('请输入正确内容'))
Expand Down

0 comments on commit 9ec2eea

Please sign in to comment.