Asp.Net MVC 2 Client validation implementation for Enterprise Library Validation Block

[亡魂溺海] 提交于 2019-12-06 10:14:33

So I could not find anything about this, so I desided to implement it on my own an publish it on codeplex http://elvalweb.codeplex.com/

Alexey, :-) i have my own implementation for validation task that is not related with EntLib, but very similar by concept. For developer it's look like the following:

   ValidationFactory.AddRule<IPerson>(
     x => string.IsNullOrEmpty(x.FirstName) &&
          string.IsNullOrEmpty(x.LastName),
     "Person should have a name", "validation set 1");
   IPerson p = UnityHelper.DefaultContainer.Resolve<IPerson>();
   ValidationResults res = ValidationFactory.Validate<IPerson>(p,"validation set 1");
   if(!res.IsValid)
   {
     foreach (ValidationResult vr in res)
     {
       var msg= vr.Message;
       var validated_instance = vr.Target;
       var Validator_instance = vr.Validator;
     }
   }   

If you are interesting in it let me know, i will cut it from my current project into separate solution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!