public void ValidateNameSuccess() { var validatepeople = new People() { Id = 2, Name = "nome teste", Document = "05765622391" }; Assert.True(validator.Validate(validatepeople).IsValid); }
public ActionResult Create(People man) { var validator = new PeopleValidator(); var result = validator.Validate(man); if (result.IsValid) { _peopleRepository.Create(man); return(RedirectToAction("Index")); } ModelState.Clear(); foreach (var error in result.Errors) { ModelState.AddModelError("", error.ErrorMessage); } return(View(man)); }