In the world of MVC I have this view model...
public class MyViewModel{
[Required]
public string FirstName{ get; set; } }
...and this s
You can write your own attribute:
public class MyRequiredAttribute : ValidationAttribute
{
MyRequiredAttribute() : base(() => "{0} blah blah blah blaaaaaah")
{
}
public override bool IsValid(object value)
{
if (value == null)
{
return false;
}
string str = value as string;
if (str != null)
{
return (str.Trim().Length != 0);
}
return true;
}
}
This is copy of RequiredAttribute from Reflector with changed error message.