从 xVal 切换到 nHibernate 验证
我有一个带有 xVal 和数据注释的 ASP.NET MVC 项目,我需要切换到 nHibernate 验证。对于数据注释,我有一个 DataAnnotationsValidationRunner,我正在做这样的事情:
var errors = DataAnnotationsValidationRunner.GetErrors(this).ToList();
if (errors.Any())
throw new RulesException(errors);
How do you do that with nHibernate.Validator?
更新:我看到了这样的东西:
var engine = new ValidatorEngine();
var errors = engine.Validate(objstovalid)
但我不能这样做,
if (errors.Any())
throw new RulesException(errors);
因为错误的类型不正确(xVal.ServerSide.ErrorInfo
)。
I have an ASP.NET MVC project with xVal and data annotations and I need to switch to nHibernate Validation. With data annotations I had a DataAnnotationsValidationRunner
and I was doing something like this:
var errors = DataAnnotationsValidationRunner.GetErrors(this).ToList();
if (errors.Any())
throw new RulesException(errors);
How do you do that with nHibernate.Validator?
Update: I saw something like this :
var engine = new ValidatorEngine();
var errors = engine.Validate(objstovalid)
but I cannot do
if (errors.Any())
throw new RulesException(errors);
because errors is not of the correct type (xVal.ServerSide.ErrorInfo
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,xVal 曾经为 NHibernate Validation 提供运行器,但它只适用于以前的版本。据我所知,当前 NHV 版本没有可用的运行程序。
只是澄清一下,您还想使用 xVal 吗?如果没有,则忽略上述内容,并在 NHV 上运行验证,如下所示:
As far as I know xVal used to provice a runner for NHibernate Validation, but it only worked on a previous version. To my knowledge there is no runner available for the current NHV version.
Just to clarify, do you still want to use xVal? If not then ignore the above, and run the validation on NHV like this: