You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered a use case in which I'd like the Prompt to validate the default value. I want to verify whether a file exists based on the provided value/default value.
I've found that when a user simply presses Enter, the validation is not triggered:
varpath=AnsiConsole.Prompt(newTextPrompt<string>("Enter [olive]file path[/]: ").DefaultValue("emails.txt").HideDefaultValue().ValidationErrorMessage("[red]Wrong path, File does not exist![/]").Validate(File.Exists));
if(DefaultValue!=null){vardefaultValue=converter(DefaultValue.Value);console.Write(IsSecret?defaultValue.Mask(Mask):defaultValue,promptStyle);console.WriteLine();// Run all validatorsif(!ValidateResult(defaultValue,outvarvalidationMessage)){console.MarkupLine(validationMessage);WritePrompt(console);continue;}returnDefaultValue.Value;}
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered:
I have encountered a use case in which I'd like the Prompt to validate the default value. I want to verify whether a file exists based on the provided value/default value.
I've found that when a user simply presses Enter, the validation is not triggered:
Possible solution:
spectre.console/src/Spectre.Console/Prompts/TextPrompt.cs
Lines 138 to 144 in 63b940c
Change to:
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: