Updated FluentValidation to 8.4.0

pull/3268/head
Taloth Saldono 5 years ago
parent 7a94725808
commit 896e824ca1

@ -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;
});
}

@ -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;
});
}

@ -4,7 +4,7 @@
<Platforms>x86</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="6.2.1.0" />
<PackageReference Include="FluentValidation" Version="8.4.0" />
<PackageReference Include="Ical.Net" Version="2.2.32" />
<PackageReference Include="Nancy" Version="1.4.4" />
<PackageReference Include="Nancy.Authentication.Basic" Version="1.4.1" />

@ -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();

@ -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();

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentMigrator.Runner" Version="1.6.2" />
<PackageReference Include="FluentValidation" Version="6.2.1.0" />
<PackageReference Include="FluentValidation" Version="8.4.0" />
<PackageReference Include="ImageResizer" Version="3.4.3" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="NLog" Version="4.5.3" />

@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="CommonServiceLocator" Version="1.3" />
<PackageReference Include="FluentAssertions" Version="4.19.0" />
<PackageReference Include="FluentValidation" Version="6.2.1.0" />
<PackageReference Include="FluentValidation" Version="8.4.0" />
<PackageReference Include="Moq" Version="4.0.10827" />
<PackageReference Include="NLog" Version="4.5.3" />
<PackageReference Include="NUnit" Version="3.6.0" />

@ -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;
});
}

@ -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;
});
}

@ -4,7 +4,7 @@
<Platforms>x86</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="6.2.1.0" />
<PackageReference Include="FluentValidation" Version="8.4.0" />
<PackageReference Include="Ical.Net" Version="2.2.32" />
<PackageReference Include="Nancy" Version="1.4.4" />
<PackageReference Include="Nancy.Authentication.Basic" Version="1.4.1" />

@ -18,7 +18,7 @@ namespace Sonarr.Http.REST
rule.DisplayName = new StaticStringSource(fieldName);
AddRule(rule);
return new RuleBuilder<TResource, TProperty>(rule);
return new RuleBuilder<TResource, TProperty>(rule, this);
}
private static object GetValue(object container, Func<TResource, IEnumerable<Field>> fieldListAccessor, string fieldName)

@ -4,7 +4,7 @@
<Platforms>x86</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="6.2.1.0" />
<PackageReference Include="FluentValidation" Version="8.4.0" />
<PackageReference Include="Nancy" Version="1.4.4" />
<PackageReference Include="Nancy.Authentication.Basic" Version="1.4.1" />
<PackageReference Include="Nancy.Authentication.Forms" Version="1.4.1" />

Loading…
Cancel
Save