Late!
I am performing a complex validation on a specific class with the following code (reduced for simplicity):
public class Classe1 : IValidatableObject
{
[Key]
public int Id_Classe1 { get; set; }
[Required]
public int Id_Estado { get; set; }
public virtual Classe2 CLASSE2 { get; set; }
public Classe1() {
CLASSE2 = new Classe2();
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) {
if (this.Id_Estado == 1)
{
if (CLASSE2.Nm_Classe2 == null)
yield return new ValidationResult("Campo Nome é obrigatório.", new string[] { "CLASSE2.Nm_Classe2" });
}
}
In the controller (ModelState.IsValid) the validation is ok. Now I need to reflect this validation on the Client Side, with unobtrusive jquery. Can anyone give me an orientation on how to do?