Fixed: No longer possible to add protocol to a Host field (that's what Url fields are for)

pull/6/head
Taloth Saldono 10 years ago
parent f2ec02876b
commit b92cc6fb15

@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
{
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 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
{
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 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
{
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 @@ namespace NzbDrone.Core.Download.Clients.Transmission
{
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 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
{
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 @@ namespace NzbDrone.Core.Notifications.Growl
{
public GrowlSettingsValidator()
{
RuleFor(c => c.Host).NotEmpty();
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
}
}

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Notifications.MediaBrowser
{
public MediaBrowserSettingsValidator()
{
RuleFor(c => c.Host).NotEmpty();
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.ApiKey).NotEmpty();
}
}

@ -10,7 +10,7 @@ namespace NzbDrone.Core.Notifications.Plex
{
public PlexClientSettingsValidator()
{
RuleFor(c => c.Host).NotEmpty();
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
}
}

@ -10,7 +10,7 @@ namespace NzbDrone.Core.Notifications.Plex
{
public PlexServerSettingsValidator()
{
RuleFor(c => c.Host).NotEmpty();
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
}
}

@ -113,7 +113,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
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 @@ namespace NzbDrone.Core.Notifications.Xbmc
{
public XbmcSettingsValidator()
{
RuleFor(c => c.Host).NotEmpty();
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.DisplayTime).GreaterThanOrEqualTo(2);
}
}

@ -19,13 +19,19 @@ namespace NzbDrone.Core.Validation
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…
Cancel
Save