public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (CustomRepository.CheckRoleExistsOrNot(RoleName, RoleId)) { var fieldName = new[] { "RoleName" }; yield return(new ValidationResult("Role is Already Exists.", fieldName)); } }