Skip to content

Commit

Permalink
Removed the validation abstraction. (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored Apr 24, 2024
1 parent 13208f8 commit 409f701
Show file tree
Hide file tree
Showing 31 changed files with 192 additions and 783 deletions.
14 changes: 0 additions & 14 deletions Fluxera.Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Extensions.Validati
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Extensions.Validation", "src\Fluxera.Extensions.Validation\Fluxera.Extensions.Validation.csproj", "{526898A1-8CD5-4147-B4F6-E74EF5E2BDAF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Extensions.Validation.DataAnnotations", "src\Fluxera.Extensions.Validation.DataAnnotations\Fluxera.Extensions.Validation.DataAnnotations.csproj", "{1B927213-5DDF-4B4C-89A6-86CFE549AEDE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Extensions.Validation.FluentValidation", "src\Fluxera.Extensions.Validation.FluentValidation\Fluxera.Extensions.Validation.FluentValidation.csproj", "{66F586A4-592B-4B58-8505-AE9976D790FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Extensions.Validation.UnitTests", "tests\Fluxera.Extensions.Validation.UnitTests\Fluxera.Extensions.Validation.UnitTests.csproj", "{FA880AC2-D0AE-4485-BABE-2FE180CA08C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Extensions.DependencyInjection.Abstractions", "src\Fluxera.Extensions.DependencyInjection.Abstractions\Fluxera.Extensions.DependencyInjection.Abstractions.csproj", "{0C7DBBD9-B259-4C03-A125-500F9B669A4D}"
Expand Down Expand Up @@ -96,14 +92,6 @@ Global
{526898A1-8CD5-4147-B4F6-E74EF5E2BDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{526898A1-8CD5-4147-B4F6-E74EF5E2BDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{526898A1-8CD5-4147-B4F6-E74EF5E2BDAF}.Release|Any CPU.Build.0 = Release|Any CPU
{1B927213-5DDF-4B4C-89A6-86CFE549AEDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B927213-5DDF-4B4C-89A6-86CFE549AEDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B927213-5DDF-4B4C-89A6-86CFE549AEDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B927213-5DDF-4B4C-89A6-86CFE549AEDE}.Release|Any CPU.Build.0 = Release|Any CPU
{66F586A4-592B-4B58-8505-AE9976D790FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66F586A4-592B-4B58-8505-AE9976D790FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66F586A4-592B-4B58-8505-AE9976D790FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66F586A4-592B-4B58-8505-AE9976D790FB}.Release|Any CPU.Build.0 = Release|Any CPU
{FA880AC2-D0AE-4485-BABE-2FE180CA08C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA880AC2-D0AE-4485-BABE-2FE180CA08C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA880AC2-D0AE-4485-BABE-2FE180CA08C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -178,8 +166,6 @@ Global
{98862534-1126-413F-8B0E-469BBD0640DB} = {F18D2D58-282C-4D93-8D9A-3A76CF98F018}
{FA970A0C-20A1-480B-95C2-E2ADD0AE0C35} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
{526898A1-8CD5-4147-B4F6-E74EF5E2BDAF} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
{1B927213-5DDF-4B4C-89A6-86CFE549AEDE} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
{66F586A4-592B-4B58-8505-AE9976D790FB} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
{FA880AC2-D0AE-4485-BABE-2FE180CA08C8} = {F18D2D58-282C-4D93-8D9A-3A76CF98F018}
{0C7DBBD9-B259-4C03-A125-500F9B669A4D} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
{F3AB84F0-8174-4C13-AD3B-E4E57D31EB66} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
Expand Down
6 changes: 3 additions & 3 deletions src/Fluxera.Extensions.Common/PasswordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
internal sealed class PasswordGenerator : IPasswordGenerator
{
// ReSharper disable StringLiteralTypo
private static readonly char[] PwdCharArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!$+-".ToCharArray();
private static readonly char[] pwdCharArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!$+-".ToCharArray();
// ReSharper restore StringLiteralTypo

private readonly RandomNumberGenerator rng;
Expand Down Expand Up @@ -95,9 +95,9 @@ private int GetCryptographicRandomNumber(int minimumValue, int maximumValue)

private char GetRandomCharacter()
{
int randomCharPosition = this.GetCryptographicRandomNumber(0, PwdCharArray.Length - 1);
int randomCharPosition = this.GetCryptographicRandomNumber(0, pwdCharArray.Length - 1);

char randomChar = PwdCharArray[randomCharPosition];
char randomChar = pwdCharArray[randomCharPosition];

return randomChar;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Fluxera.Extensions.Common/SequentialGuidGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[UsedImplicitly]
internal sealed class SequentialGuidGenerator : IGuidGenerator
{
private static readonly RandomNumberGenerator RandomNumberGenerator = RandomNumberGenerator.Create();
private static readonly RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create();
private readonly SequentialGuidGeneratorOptions options;

public SequentialGuidGenerator(IOptions<SequentialGuidGeneratorOptions> options)
Expand All @@ -33,7 +33,7 @@ private static Guid Create(SequentialGuidType guidType)
{
// We start with 16 bytes of cryptographically strong random data.
byte[] randomBytes = new byte[10];
RandomNumberGenerator.Locking(r => r.GetBytes(randomBytes));
randomNumberGenerator.Locking(r => r.GetBytes(randomBytes));

// An alternate method: use a normally-created GUID to get our initial
// random data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public interface IAccessTokenProvider
{
/// <summary>
/// Gets the access token to use in a HTTP client.
/// Gets the access token to use in an HTTP client.
/// </summary>
/// <returns></returns>
Task<string> GetAccessTokenAsync();
Expand Down
2 changes: 1 addition & 1 deletion src/Fluxera.Extensions.Http.Abstractions/RemoteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using JetBrains.Annotations;

/// <summary>
/// the remote service options.
/// The remote service options.
/// </summary>
[PublicAPI]
public sealed class RemoteService : Dictionary<string, string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluxera.Guards" Version="8.0.2" />
<PackageReference Include="FluentValidation" Version="11.9.1" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
</ItemGroup>

</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace Fluxera.Extensions.Validation
{
using System.Threading;
using System.Threading.Tasks;
using FluentValidation;
using FluentValidation.Results;
using JetBrains.Annotations;

/// <summary>
Expand All @@ -10,20 +13,37 @@
public interface IValidationService
{
/// <summary>
/// Validates the given object and returns a <see cref="ValidationResult" /> instance.
/// Validates the given object and returns a <see cref="ValidationResult" /> instance.
/// </summary>
/// <typeparam name="T">The type.</typeparam>
/// <param name="item">The instance to validate.</param>
/// <returns>The validation result.</returns>
Task<ValidationResult> ValidateAsync<T>(T item) where T : class;
/// <typeparam name="T"></typeparam>
/// <param name="item"></param>
/// <returns></returns>
public ValidationResult Validate<T>(T item);

/// <summary>
/// Validates the given object and throws a <see cref="ValidationException" /> if the validation failed.
/// Validates the given object and throws a <see cref="ValidationException" /> if invalid.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="item"></param>
/// <returns></returns>
/// <exception cref="ValidationException"></exception>
Task ThrowOnValidateAsync<T>(T item) where T : class;
public void ValidateAndThrow<T>(T item);

/// <summary>
/// Validates the given object and returns a <see cref="ValidationResult" /> instance.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="item"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task<ValidationResult> ValidateAsync<T>(T item, CancellationToken cancellationToken = default);

/// <summary>
/// Validates the given object and throws a <see cref="ValidationException" /> if invalid.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="item"></param>
/// <param name="cancellationToken"></param>
/// <exception cref="ValidationException"></exception>
public Task ValidateAndThrowAsync<T>(T item, CancellationToken cancellationToken = default);
}
}
19 changes: 0 additions & 19 deletions src/Fluxera.Extensions.Validation.Abstractions/IValidator.cs

This file was deleted.

This file was deleted.

32 changes: 0 additions & 32 deletions src/Fluxera.Extensions.Validation.Abstractions/ValidationError.cs

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions src/Fluxera.Extensions.Validation.Abstractions/ValidationResult.cs

This file was deleted.

This file was deleted.

Loading

0 comments on commit 409f701

Please sign in to comment.