From 2e3e831a6fc2cc227f9391fc39c729c613c20b65 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 29 Oct 2022 12:44:52 -0500 Subject: add top-level validation --- src/slskd/Core/Options.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index af46f23c..008151fd 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -86,7 +86,7 @@ namespace slskd /// nature of the command line string after the application is started. /// /// - public class Options + public class Options : IValidatableObject { /// /// Gets a value indicating whether to display the application version. @@ -295,6 +295,23 @@ namespace slskd [Validate] public IntegrationOptions Integration { get; init; } = new IntegrationOptions(); + /// + /// Handles top-level validation that doesn't fit anywhere else. + /// + /// + /// + public IEnumerable Validate(ValidationContext validationContext) + { + var results = new List(); + + if (InstanceName == "local" && Network.OperationMode.ToEnum() == OperationMode.Agent) + { + results.Add(new ValidationResult("Instance name must be something other than 'local' when operating in Network Agent mode")); + } + + return results; + } + /// /// Optional flags. /// -- cgit v1.2.3