private void LogLicenseValidity(IValidationContext validationContext) { if (validationContext.GetErrors().Count > 0) { Log.Warning("License is not valid:"); Log.Indent(); foreach (var error in validationContext.GetErrors()) { Log.Warning("- {0}\n{1}", error.Message, error.Tag as string); } Log.Unindent(); } else { Log.Info("License is valid"); } }
/// <summary> /// Generates Invalid request action result. /// </summary> /// <returns>Invalid request action result.</returns> protected ActionResult InvalidRequest() { if (ValidationContext.IsValid) { return(NotFound()); } return(BadRequest( new ErrorResponseDto() { Message = "Invalid request.", Errors = validationContext.GetErrors().GenerateErrorMessageDetails() })); }
public static string[] GetAlertMessages(this IValidationContext validationContext, string validationTag) { Argument.IsNotNull(() => validationContext); var stringLines = validationContext.GetErrors(validationTag).Select(s => " - " + s.Message).ToArray(); if (stringLines is null) { return(null); } var valuableLines = stringLines.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); if (!valuableLines.Any()) { return(null); } return(valuableLines); }