public async Task <IActionResult> Add(Faculty faculty) { var a = new ValidatorBuilder <Faculty>(); a.AddRulesFor(f => f.Name) .AsRequired() .WithMaxLength(20); var b = a.Build(); var c = b.Validate(faculty); if (c.Success == false) { return(BadRequest(c)); } await _facultyService.AddFaculty(faculty); return(Ok("Faculty added")); }