We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在serverless项目中,使用@midwayjs/validate中messages自定义错误信息时不生效, dto代码如下: 使用messages自定义错误信息依旧按原来的信息返回
The text was updated successfully, but these errors were encountered:
看文档,使用的是
export class UserDTO { @Rule(RuleType.number().required().error(new Error('my custom message'))) id: number; }
用的是 error,而不是 message。
Sorry, something went wrong.
用error是可以自定义错误,但只能是针对这个属性不合法触发,并不知道是违反了哪个规则; 那比如这个示例,我想在每个不同规则不满足时,提示不同的自定义错误,如它的值不为字符串则提示不是字符串,如它的值长度超过24则提示最长长度不能超过24,我想实现这样的效果要怎么做,我看 joi 的官方是可以用 messages 来做的
export class Test { @Rule( RuleType.string().min(1).max(24).required().messages({ 'any.required': 'name必填', }) ) name: string; }
No branches or pull requests
在serverless项目中,使用@midwayjs/validate中messages自定义错误信息时不生效,
dto代码如下:
使用messages自定义错误信息依旧按原来的信息返回
The text was updated successfully, but these errors were encountered: