From a3e11b24e5228b7094e72c91e2a7c6e1c541aad9 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 13 Jan 2021 19:22:19 +0100 Subject: [PATCH] (GH-226) Switch ParameterValidationAttribute check to IsNullOrWhiteSpace * fixes #226 --- src/Spectre.Console/Cli/Internal/CommandValidator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Spectre.Console/Cli/Internal/CommandValidator.cs b/src/Spectre.Console/Cli/Internal/CommandValidator.cs index 07fdca1..663fa28 100644 --- a/src/Spectre.Console/Cli/Internal/CommandValidator.cs +++ b/src/Spectre.Console/Cli/Internal/CommandValidator.cs @@ -33,9 +33,9 @@ namespace Spectre.Console.Cli.Internal { // If there is a error message specified in the parameter validator attribute, // then use that one, otherwise use the validation result. - var result = validator.ErrorMessage != null - ? ValidationResult.Error(validator.ErrorMessage) - : validationResult; + var result = string.IsNullOrWhiteSpace(validator.ErrorMessage) + ? validationResult + : ValidationResult.Error(validator.ErrorMessage); throw CommandRuntimeException.ValidationFailed(result); }