diff --git a/UrlShortener.Data/ShortUrlValidator.cs b/UrlShortener.Data/ShortUrlValidator.cs index 61627c4..1db234a 100644 --- a/UrlShortener.Data/ShortUrlValidator.cs +++ b/UrlShortener.Data/ShortUrlValidator.cs @@ -74,6 +74,6 @@ public static bool ValidatePath(string? path, out string[] validationResults) validationResultsList.Add("Path can only contain alphanumeric characters, underscores, and dashes."); validationResults = validationResultsList.ToArray(); - return validationResultsList.Count > 0; + return validationResultsList.Count == 0; } } \ No newline at end of file diff --git a/UrlShortener.Forwarder/Program.cs b/UrlShortener.Forwarder/Program.cs index be8c2cc..1bc12e2 100644 --- a/UrlShortener.Forwarder/Program.cs +++ b/UrlShortener.Forwarder/Program.cs @@ -16,8 +16,8 @@ ShortUrlRepository shortUrlRepository ) => { - if(ShortUrlValidator.ValidatePath(path, out _)) - return Results.BadRequest(); + if (!ShortUrlValidator.ValidatePath(path, out var validationResults)) + return Results.BadRequest(validationResults); var shortUrl = await shortUrlRepository.Get(path); if (shortUrl == null || string.IsNullOrEmpty(shortUrl.Destination))