I created a sample Extension method... I hope that it could help someone.
Two questions (do you want me to create new topics?):
public static void ObjectRule<T>(this AbstractValidator<T> validator, Func<T, string> customValidation)
{
validator.Custom(x =>
{
string error = customValidation(x);
if (string.IsNullOrEmpty(error))
return null;
else
return new ValidationFailure(string.Empty, error);
}
);
}
Now the could would be like:fluentValidator.ObjectRule("TEST OBJECT ERROR");
Any better (cleaner) ideas?Two questions (do you want me to create new topics?):
- Is there an ValidationRule implementation that uses DataAnnotations?
- Do you know any good IDataErrorInfo wrapper/adapter (I am currently working at it) :)