validationattribute

Custom ValidationAttribute test against whole model

I know this is probably not possible but let's say I have a model with two properties. I write a ValidationAttribute for one of the properties. Can that VA look at the other property and make a decision? So; public class QuickQuote { public String state { get; set; } [MyRequiredValidator(ErrorMessage = "Error msg")] publ...

wcf generated classes and validation application block attributes

Hi, I'm new to the validation application block and trying to use it with wcf... I have a wcf service that has data objects with validation rules defined with attributes, using the validation application block . On my client side (WPF), I have a service reference. When I update the service reference the generated classes do not have th...

Validationattribute only when value is changed?

I want to write a custom ValidationAttribute that checks if the given value is unique or not. The problem is that in the edit screen, it is not guaranteed that the user actually changed the value, resulting in a false error. Is there a way to check in my attribute whether the value actually changed? Or can I trigger the attribute onl...

How come module-level validators are evaluated only after property-level validators?

I'm using the module-level validator: 'PropertiesMustMatch' on my view-model, like so: [PropertiesMustMatch("Password", "PasswordConfirm")] public class HomeIndex { [Required] public string Name { get; set; } public string Password { get; set; } public string PasswordConfirm { get; set; } } I'm noticing that if I sub...

.Net MVC2 How to add error to ModelState when using custom ValidationAttribute - Solved with IDataErrorInfo

I have the following ValidationAttribute class [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class DateValidationAttribute : ValidationAttribute { public DateValidationAttribute(string leftDateProperty, CompareOperator compareOperator, string rightDateProperty, string errorMessage) ...

Will the ValidationResult.MemberNames property ever contain more than one value?

I search with reflector and I didn't manage to find a case where the ValidationResult.MemberNames is supposed to contain more than one value. So, first of all I am wondering why MS had to do it IEnumerable<string>, then now that they already did this, can I rely that this property will only return one value? Update Conserning the DataA...