//Propiedad de la clase "Usuario" con sus respectivas validaciones
[ValidateDNIRepetit(ErrorMessage = "El correo ya existe")]
[Required(ErrorMessage = "El campo no puede estar vacio")]
[EmailAddress(ErrorMessage = "No es una dirección de correo válida")]
public string Email { get; set; }
//Implementación de la propiedad de dicha clase en cualquier vista Razor, pues la uso en varias
<div class="form-group">
@Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })
</div>
</div>
Do I have any way of choosing in a particular view which of the 3 validations of the property to use? Well, in one of the forms I do not need the validation "ValidateDNIRepetit", but the other 2 yes. Thanks