I am trying to make my own ValidationAttribute but when I need the "value" it is null.
I have my ViewModel like this
public class PacienteVerificarVM : IIdentifiableObject
{
[DniFormatoCorrecto]
public string NumeroDocumento { get; set; }
}
and my controller method is
public ActionResult ResultadoBusqueda(PacienteVerificarVM viewmodel)
{
if (!ModelState.IsValid)
return RedirectToAction("CreateDocumento");
return PartialView();
}
and my Validation attribute is:
public class DniFormatoCorrecto : ValidationAttribute
{
protected override ValidationResult IsValid(object value,
ValidationContext validationContext)
{
return ValidationResult.Success;
}
}
Any idea?