我要传递增值税值。如果验证为空或通过了某个国家/地区的指定正则表达式,则验证应允许将其保存在数据库中。
.when('country_code', {
is: 'AT',
then: Joi.alternatives([
Joi.string().allow(''),
Joi.string().regex(/(AT)?U[0-9]{8}/)
])
})
这是我到目前为止所实现的,但是没有用。
答案 0 :(得分:1)
这是您要寻找的:
Joi.string().regex(/(AT)?U[0-9]{8}$/).allow('')