mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01: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
@ -10,7 +10,7 @@ public class DelugeSettingsValidator : AbstractValidator<DelugeSettings>
|
||||
{
|
||||
public DelugeSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).GreaterThan(0);
|
||||
|
||||
RuleFor(c => c.TvCategory).Matches("^[-a-z]*$").WithMessage("Allowed characters a-z and -");
|
||||
|
@ -10,7 +10,7 @@ public class NzbgetSettingsValidator : AbstractValidator<NzbgetSettings>
|
||||
{
|
||||
public NzbgetSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).GreaterThan(0);
|
||||
RuleFor(c => c.Username).NotEmpty().When(c => !String.IsNullOrWhiteSpace(c.Password));
|
||||
RuleFor(c => c.Password).NotEmpty().When(c => !String.IsNullOrWhiteSpace(c.Username));
|
||||
|
@ -10,7 +10,7 @@ public class SabnzbdSettingsValidator : AbstractValidator<SabnzbdSettings>
|
||||
{
|
||||
public SabnzbdSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).GreaterThan(0);
|
||||
|
||||
RuleFor(c => c.ApiKey).NotEmpty()
|
||||
|
@ -10,7 +10,7 @@ public class TransmissionSettingsValidator : AbstractValidator<TransmissionSetti
|
||||
{
|
||||
public TransmissionSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).GreaterThan(0);
|
||||
|
||||
RuleFor(c => c.TvCategory).Matches(@"^\.?[-a-z]*$").WithMessage("Allowed characters a-z and -");
|
||||
|
@ -10,7 +10,7 @@ public class UTorrentSettingsValidator : AbstractValidator<UTorrentSettings>
|
||||
{
|
||||
public UTorrentSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
|
||||
RuleFor(c => c.TvCategory).NotEmpty();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class GrowlSettingsValidator : AbstractValidator<GrowlSettings>
|
||||
{
|
||||
public GrowlSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).GreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class MediaBrowserSettingsValidator : AbstractValidator<MediaBrowserSetti
|
||||
{
|
||||
public MediaBrowserSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.ApiKey).NotEmpty();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class PlexClientSettingsValidator : AbstractValidator<PlexClientSettings>
|
||||
{
|
||||
public PlexClientSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).GreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class PlexServerSettingsValidator : AbstractValidator<PlexServerSettings>
|
||||
{
|
||||
public PlexServerSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).GreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public ValidationFailure Test(XbmcSettings settings)
|
||||
|
||||
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!");
|
||||
|
@ -12,7 +12,7 @@ public class XbmcSettingsValidator : AbstractValidator<XbmcSettings>
|
||||
{
|
||||
public XbmcSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).NotEmpty();
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user