Skip to content
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

Form表单验证必填项字段多个验证时星号(*)不提示 #41

Open
icnz opened this issue Dec 7, 2023 · 0 comments
Open

Form表单验证必填项字段多个验证时星号(*)不提示 #41

icnz opened this issue Dec 7, 2023 · 0 comments

Comments

@icnz
Copy link

icnz commented Dec 7, 2023

背景

使用Form验证时,必填项的label栏会有红色的星号(*)提示,验证正常,如下:

const formRules = ref<any>({
  name: {
      type: 'string',
      required: true,
    }
})

但当某个字段有多个验证时,红色星号(*)提示不显示,但验证正常,如下:

const formRules = ref<any>({
  name: [
    {
      type: 'string',
      required: true,
    },
    {
      pattern: /^[0-9A-Za-z]{4,20}$/,
      message: "用户名须为4-20位英文、数字或英数组合",
      required: true,
    },
  ]
})

这个问题应该是layer-vue的验证逻辑问题
目前的解决方案是对Form的验证字段动态设置required属性,可以暂时解决问题,但这样增加了很多不必要的验证代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant