aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-01 10:02:37 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-07-01 10:02:37 -0500
commit34a25f488eecee202cbed8d8c2ee64bd60439ab4 (patch)
treecb783a25f49e870c08112ece72dc5dc74e6dad25 /src/slskd
parentaf0c79be657bd4dd56dc2ef3ccc6bb64c4328162 (diff)
downloadslskd-34a25f488eecee202cbed8d8c2ee64bd60439ab4.tar.gz
add validator to ensure Address if FTP is Enabled
Diffstat (limited to 'src/slskd')
-rw-r--r--src/slskd/Options.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs
index e32ef522..f8190fc7 100644
--- a/src/slskd/Options.cs
+++ b/src/slskd/Options.cs
@@ -18,6 +18,7 @@
namespace slskd
{
using System;
+ using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
@@ -569,7 +570,7 @@ namespace slskd
/// <summary>
/// FTP options.
/// </summary>
- public class FTPOptions
+ public class FTPOptions : IValidatableObject
{
/// <summary>
/// Gets a value indicating whether the FTP integration is enabled.
@@ -662,6 +663,18 @@ namespace slskd
[Description("number of times failing FTP uploads will be retried")]
[Range(0, 5)]
public int RetryAttempts { get; private set; } = 3;
+
+ public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
+ {
+ var results = new List<ValidationResult>();
+
+ if (Enabled && string.IsNullOrWhiteSpace(Address))
+ {
+ results.Add(new ValidationResult($"The Enabled field is true, but no Address has been specified."));
+ }
+
+ return results;
+ }
}
}
}