From 210871add72e8ad22661194c6f630fc1ecee140f Mon Sep 17 00:00:00 2001 From: Thomas Blitz <5293103+tlogik@users.noreply.github.com> Date: Sun, 3 Nov 2024 05:36:17 +0100 Subject: [PATCH] docs: fix incorrect validation example (#551) The documented use of Accepts was incorrect and has been corrected [ci skip] --------- Co-authored-by: Nate McMaster --- docs/samples/validation/attributes/Program.cs | 1 + docs/samples/validation/builder-api/Program.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/samples/validation/attributes/Program.cs b/docs/samples/validation/attributes/Program.cs index 1eba78eb..a70af9f2 100644 --- a/docs/samples/validation/attributes/Program.cs +++ b/docs/samples/validation/attributes/Program.cs @@ -50,6 +50,7 @@ private void OnExecute() Console.WriteLine("To = " + To); Console.WriteLine("Message = " + Message); Console.WriteLine("Attachments = " + string.Join(", ", Attachments)); + Console.WriteLine("Importance = " + Importance); if (MaxSize.HasValue) { Console.WriteLine("Max size = " + MaxSize.Value); diff --git a/docs/samples/validation/builder-api/Program.cs b/docs/samples/validation/builder-api/Program.cs index 116a2eff..129a2698 100644 --- a/docs/samples/validation/builder-api/Program.cs +++ b/docs/samples/validation/builder-api/Program.cs @@ -27,7 +27,7 @@ public static int Main(string[] args) .Accepts(v => v.ExistingFile()); var importance = app.Option("-i|--importance ", "Low, medium or high", CommandOptionType.SingleValue) - .Accepts().Values("low", "medium", "high"); + .Accepts(v => v.Values("low", "medium", "high")); var optionColor = app.Option("--color ", "The color. Should be 'red' or 'blue'.", CommandOptionType.SingleValue); optionColor.Validators.Add(new MustBeBlueOrRedValidator()); @@ -41,6 +41,7 @@ public static int Main(string[] args) Console.WriteLine("To = " + optionReceiver.Value()); Console.WriteLine("Message = " + optionMessage.Value()); Console.WriteLine("Attachments = " + string.Join(", ", attachments.Values)); + Console.WriteLine("Importance = " + importance.Value()); if (optionMaxSize.HasValue()) { Console.WriteLine("Max size = " + optionMaxSize.ParsedValue);