【发布时间】:2019-07-09 06:57:00
【问题描述】:
如何验证不应包含以下特殊字符 #<`> 和点之前的空格的非必需字段(。)我有正则表达式 \`|\#|\&|\<|\ \.|\> 来验证上述条件,但不知道该怎么做带有 yup.matches() 的正则表达式。在此先感谢
Regex: \`|\#|\&|\<|\ \.|\>
我的验证模式是:
const validationSchema = function (values) {
var regx = new RegExp(/\`|\#|\&|\<|\ \.|\>/gms);
return Yup.object().shape({
about: Yup.string()
.matches(expression, 'about should not contain ` # < > \n')
})
}
【问题讨论】: