From 3834633fffc784bb06d4e69459c8c4748f0b6ae9 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Jan 2026 18:46:13 -0600 Subject: document patch, add extension to validate --- src/slskd/Common/Validation/Extensions.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/slskd/Common') diff --git a/src/slskd/Common/Validation/Extensions.cs b/src/slskd/Common/Validation/Extensions.cs index b7e396a3..6233d53b 100644 --- a/src/slskd/Common/Validation/Extensions.cs +++ b/src/slskd/Common/Validation/Extensions.cs @@ -44,5 +44,25 @@ namespace slskd.Validation return true; } + + /// + /// Validates options. + /// + /// The options patch instance to validate. + /// The result of the validation, if invalid. + /// A value indicating whether the instance is valid. + public static bool TryValidate(this OptionsPatch patch, out CompositeValidationResult result) + { + result = null; + var results = new List(); + + if (!Validator.TryValidateObject(patch, new ValidationContext(patch), results, true)) + { + result = new CompositeValidationResult("Invalid configuration", results); + return false; + } + + return true; + } } } \ No newline at end of file -- cgit v1.2.3