I'm having some trouble understanding validation logic behing DataAnnotation validation :
With the following model :
[AlwaysInvalid]
public class TestModel
{
[Required]
public string Test { get; set; }
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public class AlwaysInvalidAttribute : ValidationAttribute
{
private readonly object typeId = new object();
public AlwaysInvalidAttribute() : base("Fail !") {}
public override object TypeId { get { return this.typeId; } }
public override bool IsValid(object value)
{
return false;
}
}
The AlwaysInvalidAttribute error message gets displayed only if the Required attribute is valid : I can't get both messages at the same time. Anyone got an idea why ? I think it's an issue with DefaultModelBinder, but still haven't found where, or why.