diff --git a/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs b/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
index 636979d86..f14e4a487 100644
--- a/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
+++ b/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
@@ -28,14 +28,12 @@ namespace NzbDrone.Api.Profiles.Delay
SharedValidator.RuleFor(d => d.UsenetDelay).GreaterThanOrEqualTo(0);
SharedValidator.RuleFor(d => d.TorrentDelay).GreaterThanOrEqualTo(0);
- SharedValidator.Custom(delayProfile =>
+ SharedValidator.RuleFor(d => d).Custom((delayProfile, context) =>
{
if (!delayProfile.EnableUsenet && !delayProfile.EnableTorrent)
{
- return new ValidationFailure("", "Either Usenet or Torrent should be enabled");
+ context.AddFailure("Either Usenet or Torrent should be enabled");
}
-
- return null;
});
}
diff --git a/src/NzbDrone.Api/Restrictions/RestrictionModule.cs b/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
index 7188e57fb..c5c80574e 100644
--- a/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
+++ b/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Profiles.Releases;
@@ -22,14 +23,12 @@ namespace NzbDrone.Api.Restrictions
UpdateResource = UpdateRestriction;
DeleteResource = DeleteRestriction;
- SharedValidator.Custom(restriction =>
+ SharedValidator.RuleFor(r => r).Custom((restriction, context) =>
{
if (restriction.Ignored.IsNullOrWhiteSpace() && restriction.Required.IsNullOrWhiteSpace())
{
- return new ValidationFailure("", "Either 'Must contain' or 'Must not contain' is required");
+ context.AddFailure("Either 'Must contain' or 'Must not contain' is required");
}
-
- return null;
});
}
diff --git a/src/NzbDrone.Api/Sonarr.Api.csproj b/src/NzbDrone.Api/Sonarr.Api.csproj
index 52389eeb8..c60916e61 100644
--- a/src/NzbDrone.Api/Sonarr.Api.csproj
+++ b/src/NzbDrone.Api/Sonarr.Api.csproj
@@ -4,7 +4,7 @@
x86
-
+
diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs
index ee7bd3d9d..bd7d78c17 100644
--- a/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs
+++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs
@@ -37,14 +37,12 @@ namespace NzbDrone.Core.Indexers.Newznab
public NewznabSettingsValidator()
{
- Custom(newznab =>
+ RuleFor(c => c).Custom((c, context) =>
{
- if (newznab.Categories.Empty() && newznab.AnimeCategories.Empty())
+ if (c.Categories.Empty() && c.AnimeCategories.Empty())
{
- return new ValidationFailure("", "Either 'Categories' or 'Anime Categories' must be provided");
+ context.AddFailure("Either 'Categories' or 'Anime Categories' must be provided");
}
-
- return null;
});
RuleFor(c => c.BaseUrl).ValidRootUrl();
diff --git a/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs b/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs
index dc8e8eab2..476ba1932 100644
--- a/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs
+++ b/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs
@@ -30,14 +30,12 @@ namespace NzbDrone.Core.Indexers.Torznab
public TorznabSettingsValidator()
{
- Custom(newznab =>
+ RuleFor(c => c).Custom((c, context) =>
{
- if (newznab.Categories.Empty() && newznab.AnimeCategories.Empty())
+ if (c.Categories.Empty() && c.AnimeCategories.Empty())
{
- return new ValidationFailure("", "Either 'Categories' or 'Anime Categories' must be provided");
+ context.AddFailure("Either 'Categories' or 'Anime Categories' must be provided");
}
-
- return null;
});
RuleFor(c => c.BaseUrl).ValidRootUrl();
diff --git a/src/NzbDrone.Core/Sonarr.Core.csproj b/src/NzbDrone.Core/Sonarr.Core.csproj
index 70f42cd39..8837b1172 100644
--- a/src/NzbDrone.Core/Sonarr.Core.csproj
+++ b/src/NzbDrone.Core/Sonarr.Core.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/NzbDrone.Test.Common/Sonarr.Test.Common.csproj b/src/NzbDrone.Test.Common/Sonarr.Test.Common.csproj
index 5220c1dec..616f6d90c 100644
--- a/src/NzbDrone.Test.Common/Sonarr.Test.Common.csproj
+++ b/src/NzbDrone.Test.Common/Sonarr.Test.Common.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/src/Sonarr.Api.V3/Profiles/Delay/DelayProfileModule.cs b/src/Sonarr.Api.V3/Profiles/Delay/DelayProfileModule.cs
index 9613c75bd..d6f106ac9 100644
--- a/src/Sonarr.Api.V3/Profiles/Delay/DelayProfileModule.cs
+++ b/src/Sonarr.Api.V3/Profiles/Delay/DelayProfileModule.cs
@@ -32,14 +32,12 @@ namespace Sonarr.Api.V3.Profiles.Delay
SharedValidator.RuleFor(d => d.UsenetDelay).GreaterThanOrEqualTo(0);
SharedValidator.RuleFor(d => d.TorrentDelay).GreaterThanOrEqualTo(0);
- SharedValidator.Custom(delayProfile =>
+ SharedValidator.RuleFor(d => d).Custom((delayProfile, context) =>
{
if (!delayProfile.EnableUsenet && !delayProfile.EnableTorrent)
{
- return new ValidationFailure("", "Either Usenet or Torrent should be enabled");
+ context.AddFailure("Either Usenet or Torrent should be enabled");
}
-
- return null;
});
}
diff --git a/src/Sonarr.Api.V3/Profiles/Release/ReleaseProfileModule.cs b/src/Sonarr.Api.V3/Profiles/Release/ReleaseProfileModule.cs
index c87662357..9e61585c4 100644
--- a/src/Sonarr.Api.V3/Profiles/Release/ReleaseProfileModule.cs
+++ b/src/Sonarr.Api.V3/Profiles/Release/ReleaseProfileModule.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Profiles.Releases;
@@ -21,14 +22,12 @@ namespace Sonarr.Api.V3.Profiles.Release
UpdateResource = Update;
DeleteResource = DeleteReleaseProfile;
- SharedValidator.Custom(restriction =>
+ SharedValidator.RuleFor(d => d).Custom((restriction, context) =>
{
if (restriction.Ignored.IsNullOrWhiteSpace() && restriction.Required.IsNullOrWhiteSpace() && restriction.Preferred.Empty())
{
- return new ValidationFailure("", "'Must contain', 'Must not contain' or 'Preferred' is required");
+ context.AddFailure("'Must contain', 'Must not contain' or 'Preferred' is required");
}
-
- return null;
});
}
diff --git a/src/Sonarr.Api.V3/Sonarr.Api.V3.csproj b/src/Sonarr.Api.V3/Sonarr.Api.V3.csproj
index 87b9433d2..e4a1206ec 100644
--- a/src/Sonarr.Api.V3/Sonarr.Api.V3.csproj
+++ b/src/Sonarr.Api.V3/Sonarr.Api.V3.csproj
@@ -4,7 +4,7 @@
x86
-
+
diff --git a/src/Sonarr.Http/REST/ResourceValidator.cs b/src/Sonarr.Http/REST/ResourceValidator.cs
index 6f91bf8f0..4e4662ee8 100644
--- a/src/Sonarr.Http/REST/ResourceValidator.cs
+++ b/src/Sonarr.Http/REST/ResourceValidator.cs
@@ -18,7 +18,7 @@ namespace Sonarr.Http.REST
rule.DisplayName = new StaticStringSource(fieldName);
AddRule(rule);
- return new RuleBuilder(rule);
+ return new RuleBuilder(rule, this);
}
private static object GetValue(object container, Func> fieldListAccessor, string fieldName)
diff --git a/src/Sonarr.Http/Sonarr.Http.csproj b/src/Sonarr.Http/Sonarr.Http.csproj
index 90f53aa36..b03f142c3 100644
--- a/src/Sonarr.Http/Sonarr.Http.csproj
+++ b/src/Sonarr.Http/Sonarr.Http.csproj
@@ -4,7 +4,7 @@
x86
-
+