.NET核心自定义数据注释验证带有错误代码
对于.NET Core中的自定义验证,我正在使用system.com.ponentmodel.dataannotations.dataannotations.validationatatattribute
注释,我正在覆盖iSvalid
方法,如图所示在这里。
现在,我想为每个错误消息添加错误代码,以便每个错误消息也将具有关联的错误代码。
如何实现?
For custom validations in .NET Core I am using the System.ComponentModel.DataAnnotations.ValidationAttribute
annotation, and I'm overriding the IsValid
method as shown here.
Now I want to add error codes for each error message, so that each error message will have an associated error code as well.
How this can be achieved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在下面尝试过,这是您想要的吗?:
自定义valiateattribute:
model:
testResult:

I tried as below,Is it what you want?:
the custom validateAttribute:
Model:
The testResult:
