简体   繁体   English

是否可以在域模型项目中使用MVC防呆验证

[英]Is it possible to use MVC Foolproof Validation in a domain model project

I am trying to validate two fields based on the URL entered using a RequiredIf data annotation provided by MVC Foolproof Validation, the project is an n-layer web application with business logic, data tier, presentation and unit testing layers. 我试图根据使用MVC Foolproof Validation提供的RequiredIf数据注释输入的URL验证两个字段,该项目是一个具有业务逻辑,数据层,表示层和单元测试层的n层Web应用程序。

The validation is currently being handled in the domain project found in the business logic layer, I have used this package successfully in other project but so far not got it to work in this project. 目前,验证是在业务逻辑层中的域项目中处理的,我已经在其他项目中成功使用了此程序包,但到目前为止尚未在该项目中使用它。

when I run the application in the web browser the field is not marked as required and the form can be submitted without entering one or other of these two fields. 当我在Web浏览器中运行该应用程序时,该字段未标记为必填字段,并且无需输入这两个字段中的任何一个即可提交表单。

for more details please refer to question I asked previously found here: 有关更多详细信息,请参阅我之前在这里找到的问题:

validating textboxes based on the URL entered 根据输入的URL验证文本框

I have implemented a custom validator so far which does catch error but the user is unware that the field is actually required until they have submitted the form without entering a value. 到目前为止,我已经实现了一个自定义验证器,它确实捕获了错误,但是用户并不知道该字段实际上是必填字段,直到他们提交表单而不输入值。

After looking at a number of MVC 4 projects using an n-tier architecture, in particular ProDinner which can be found here: 在查看了许多使用n层体系结构的MVC 4项目之后,尤其是ProDinner,可以在这里找到:

http://prodinner.codeplex.com/ http://prodinner.codeplex.com/

I have now decided to refactor the application so that the domain (core) now implements the model as POCOs and then the validation is implemented in a view model within the MVC project that inherits from the domain model. 我现在决定重构应用程序,以便域(核心)现在将模型实现为POCO,然后在继承自域模型的MVC项目中的视图模型中实现验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM