Asp.Net MVC 2 Implementing Client Verification for Enterprise Library Health Check Block
I found a very good article on how to use an EntLib validator to validate a server in MVC 2. But as noted,
The current project for the Application Validation EntLibs block uses the Composite pattern; that is, when we ask for confirmation for an object, it returns back one validator object containing a list of all the checks that need to be performed. While this is very convenient from a typical use case, the unfortunate side effect is that we cannot "look inside" to see what its individual checks are doing, and therefore cannot generate appropriate client-side validation hints.
So how can you implement client side validation for EntLib? Is there a job?
a source to share
So I couldn't find anything about it, so I decided to implement it myself, post it on codeplex http://elvalweb.codeplex.com/
a source to share
Alexey, :-) I have my own implementation for a validation task that is not related to EntLib, but is very similar in concept. For a developer, it looks like this:
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 interested in this, let me know, I will shrink it from my current project into a separate solution.
a source to share