Skip to content

Commit

Permalink
docs: fix incorrect validation example (#551)
Browse files Browse the repository at this point in the history
The documented use of Accepts was incorrect and has been corrected

[ci skip]
---------

Co-authored-by: Nate McMaster <[email protected]>
  • Loading branch information
tlogik and natemcmaster authored Nov 3, 2024
1 parent d463a5c commit 210871a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/samples/validation/attributes/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion docs/samples/validation/builder-api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static int Main(string[] args)
.Accepts(v => v.ExistingFile());

var importance = app.Option("-i|--importance <IMPORTANCE>", "Low, medium or high", CommandOptionType.SingleValue)
.Accepts().Values("low", "medium", "high");
.Accepts(v => v.Values("low", "medium", "high"));

var optionColor = app.Option("--color <COLOR>", "The color. Should be 'red' or 'blue'.", CommandOptionType.SingleValue);
optionColor.Validators.Add(new MustBeBlueOrRedValidator());
Expand All @@ -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);
Expand Down

0 comments on commit 210871a

Please sign in to comment.