diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-07-01 10:02:37 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-07-01 10:02:37 -0500 |
| commit | 34a25f488eecee202cbed8d8c2ee64bd60439ab4 (patch) | |
| tree | cb783a25f49e870c08112ece72dc5dc74e6dad25 /src | |
| parent | af0c79be657bd4dd56dc2ef3ccc6bb64c4328162 (diff) | |
| download | slskd-34a25f488eecee202cbed8d8c2ee64bd60439ab4.tar.gz | |
add validator to ensure Address if FTP is Enabled
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Options.cs | 15 |
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; + } } } } |
