mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-21 05:27:03 +00:00
Fixed: No longer possible to add protocol to a Host field (that's what Url fields are for)
This commit is contained in:
parent
f2ec02876b
commit
b92cc6fb15
12 changed files with 19 additions and 13 deletions
|
@ -10,7 +10,7 @@ public class DelugeSettingsValidator : AbstractValidator<DelugeSettings>
|
||||||
{
|
{
|
||||||
public DelugeSettingsValidator()
|
public DelugeSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).GreaterThan(0);
|
RuleFor(c => c.Port).GreaterThan(0);
|
||||||
|
|
||||||
RuleFor(c => c.TvCategory).Matches("^[-a-z]*$").WithMessage("Allowed characters a-z and -");
|
RuleFor(c => c.TvCategory).Matches("^[-a-z]*$").WithMessage("Allowed characters a-z and -");
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class NzbgetSettingsValidator : AbstractValidator<NzbgetSettings>
|
||||||
{
|
{
|
||||||
public NzbgetSettingsValidator()
|
public NzbgetSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).GreaterThan(0);
|
RuleFor(c => c.Port).GreaterThan(0);
|
||||||
RuleFor(c => c.Username).NotEmpty().When(c => !String.IsNullOrWhiteSpace(c.Password));
|
RuleFor(c => c.Username).NotEmpty().When(c => !String.IsNullOrWhiteSpace(c.Password));
|
||||||
RuleFor(c => c.Password).NotEmpty().When(c => !String.IsNullOrWhiteSpace(c.Username));
|
RuleFor(c => c.Password).NotEmpty().When(c => !String.IsNullOrWhiteSpace(c.Username));
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class SabnzbdSettingsValidator : AbstractValidator<SabnzbdSettings>
|
||||||
{
|
{
|
||||||
public SabnzbdSettingsValidator()
|
public SabnzbdSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).GreaterThan(0);
|
RuleFor(c => c.Port).GreaterThan(0);
|
||||||
|
|
||||||
RuleFor(c => c.ApiKey).NotEmpty()
|
RuleFor(c => c.ApiKey).NotEmpty()
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class TransmissionSettingsValidator : AbstractValidator<TransmissionSetti
|
||||||
{
|
{
|
||||||
public TransmissionSettingsValidator()
|
public TransmissionSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).GreaterThan(0);
|
RuleFor(c => c.Port).GreaterThan(0);
|
||||||
|
|
||||||
RuleFor(c => c.TvCategory).Matches(@"^\.?[-a-z]*$").WithMessage("Allowed characters a-z and -");
|
RuleFor(c => c.TvCategory).Matches(@"^\.?[-a-z]*$").WithMessage("Allowed characters a-z and -");
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class UTorrentSettingsValidator : AbstractValidator<UTorrentSettings>
|
||||||
{
|
{
|
||||||
public UTorrentSettingsValidator()
|
public UTorrentSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
|
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
|
||||||
RuleFor(c => c.TvCategory).NotEmpty();
|
RuleFor(c => c.TvCategory).NotEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class GrowlSettingsValidator : AbstractValidator<GrowlSettings>
|
||||||
{
|
{
|
||||||
public GrowlSettingsValidator()
|
public GrowlSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).GreaterThan(0);
|
RuleFor(c => c.Port).GreaterThan(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class MediaBrowserSettingsValidator : AbstractValidator<MediaBrowserSetti
|
||||||
{
|
{
|
||||||
public MediaBrowserSettingsValidator()
|
public MediaBrowserSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.ApiKey).NotEmpty();
|
RuleFor(c => c.ApiKey).NotEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class PlexClientSettingsValidator : AbstractValidator<PlexClientSettings>
|
||||||
{
|
{
|
||||||
public PlexClientSettingsValidator()
|
public PlexClientSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).GreaterThan(0);
|
RuleFor(c => c.Port).GreaterThan(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class PlexServerSettingsValidator : AbstractValidator<PlexServerSettings>
|
||||||
{
|
{
|
||||||
public PlexServerSettingsValidator()
|
public PlexServerSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).GreaterThan(0);
|
RuleFor(c => c.Port).GreaterThan(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public ValidationFailure Test(XbmcSettings settings)
|
||||||
|
|
||||||
if (version == new XbmcVersion(0))
|
if (version == new XbmcVersion(0))
|
||||||
{
|
{
|
||||||
throw new InvalidXbmcVersionException("Verion received from XBMC is invalid, please correct your settings.");
|
throw new InvalidXbmcVersionException("Version received from XBMC is invalid, please correct your settings.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Notify(settings, "Test Notification", "Success! XBMC has been successfully configured!");
|
Notify(settings, "Test Notification", "Success! XBMC has been successfully configured!");
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class XbmcSettingsValidator : AbstractValidator<XbmcSettings>
|
||||||
{
|
{
|
||||||
public XbmcSettingsValidator()
|
public XbmcSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).NotEmpty();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.DisplayTime).GreaterThanOrEqualTo(2);
|
RuleFor(c => c.DisplayTime).GreaterThanOrEqualTo(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,19 @@ public static IRuleBuilderOptions<T, int> IsZero<T>(this IRuleBuilder<T, int> ru
|
||||||
|
|
||||||
public static IRuleBuilderOptions<T, string> HaveHttpProtocol<T>(this IRuleBuilder<T, string> ruleBuilder)
|
public static IRuleBuilderOptions<T, string> HaveHttpProtocol<T>(this IRuleBuilder<T, string> ruleBuilder)
|
||||||
{
|
{
|
||||||
return ruleBuilder.SetValidator(new RegularExpressionValidator("^http(s)?://", RegexOptions.IgnoreCase)).WithMessage("must start with http:// or https://");
|
return ruleBuilder.SetValidator(new RegularExpressionValidator("^https?://", RegexOptions.IgnoreCase)).WithMessage("must start with http:// or https://");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IRuleBuilderOptions<T, string> ValidHost<T>(this IRuleBuilder<T, string> ruleBuilder)
|
||||||
|
{
|
||||||
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||||
|
return ruleBuilder.SetValidator(new RegularExpressionValidator("^[-a-z0-9.]+$", RegexOptions.IgnoreCase)).WithMessage("must be valid Host without http://");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IRuleBuilderOptions<T, string> ValidRootUrl<T>(this IRuleBuilder<T, string> ruleBuilder)
|
public static IRuleBuilderOptions<T, string> ValidRootUrl<T>(this IRuleBuilder<T, string> ruleBuilder)
|
||||||
{
|
{
|
||||||
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||||
return ruleBuilder.SetValidator(new RegularExpressionValidator("^http(?:s)?://[a-z0-9-.]+", RegexOptions.IgnoreCase)).WithMessage("must be valid URL that");
|
return ruleBuilder.SetValidator(new RegularExpressionValidator("^https?://[-a-z0-9.]+", RegexOptions.IgnoreCase)).WithMessage("must be valid URL that starts with http(s)://");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IRuleBuilderOptions<T, int> ValidPort<T>(this IRuleBuilder<T, int> ruleBuilder)
|
public static IRuleBuilderOptions<T, int> ValidPort<T>(this IRuleBuilder<T, int> ruleBuilder)
|
||||||
|
|
Loading…
Reference in a new issue