i have a View Model
[CustomValidation(typeof(MyValidation), "MyMethod")]
[Serializable()]
public class TransactionViewModel
{
public string InvoiceNumber;
}
public class MyValidation
{
public static ValidationResult validatelength(TransactionViewModel length)
{
bool isValid;
if (length.InvoiceNumber.Length >15)
isValid = false;
else
isValid = true;
if (isValid)
{
return ValidationResult.Success;
}
else
{
return new ValidationResult(
"The Field value is greater than 15");
}
}
}
now i am checking some fields of my class object if Validation fails i am checking the model state in controller and return the View ,Added Validation Message for the Invoice Number But still am not getting the Errors
Can we Apply validation Attribute to Model View ,PLS provide the the Solution if i am doing anything wrong