value
在你的规则中
不
一个字符串,但它是一个字符串数组。正则表达式
test
函数使用array.toString()将数组强制转换为单个字符串。
a值
['[email protected]', 'notanemail']
然后按照以下方式进行测试
'[email protected],notanemail'
您的测试正在寻找单个
@
字符然后返回true。您需要循环数组,而不是让正则表达式将其强制转换为字符串。
const emailRule = [ (values: string[]) => {
if (!values) return true
for (const val of values) {
if(!/.+@.+/.test(val)) return 'Invalid Email address'
}
return true
}]
Vuetify Playground example