From a5070bc32b80fc2aef60d438fd5e5bb24f55dac2 Mon Sep 17 00:00:00 2001 From: Francis Pion Date: Thu, 19 Dec 2024 19:29:01 -0500 Subject: [PATCH] cleanup --- .../Shared/CustomIdentifierKeyValidator.cs | 19 --------- .../Shared/CustomIdentifierValidator.cs | 41 ------------------- .../Shared/CustomIdentifierValueValidator.cs | 24 ----------- .../Shared/FutureValidator.cs | 20 --------- .../Shared/ICustomIdentifierValidator.cs | 26 ------------ .../Shared/PastValidator.cs | 20 --------- .../Users/UserAggregate.cs | 2 - 7 files changed, 152 deletions(-) delete mode 100644 old/src/Logitar.Identity.Domain/Shared/CustomIdentifierKeyValidator.cs delete mode 100644 old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValidator.cs delete mode 100644 old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValueValidator.cs delete mode 100644 old/src/Logitar.Identity.Domain/Shared/FutureValidator.cs delete mode 100644 old/src/Logitar.Identity.Domain/Shared/ICustomIdentifierValidator.cs delete mode 100644 old/src/Logitar.Identity.Domain/Shared/PastValidator.cs diff --git a/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierKeyValidator.cs b/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierKeyValidator.cs deleted file mode 100644 index 59ad988..0000000 --- a/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierKeyValidator.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentValidation; - -namespace Logitar.Identity.Domain.Shared; - -/// -/// The validator used to validate custom identifier keys. -/// See for more information. -/// -public class CustomIdentifierKeyValidator : AbstractValidator -{ - /// - /// Initializes a new instance of the class. - /// - /// The name of the property, used for validation. - public CustomIdentifierKeyValidator(string? propertyName = null) - { - RuleFor(x => x).SetValidator(new IdentifierValidator()).WithPropertyName(propertyName); - } -} diff --git a/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValidator.cs b/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValidator.cs deleted file mode 100644 index a44ece0..0000000 --- a/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValidator.cs +++ /dev/null @@ -1,41 +0,0 @@ -using FluentValidation; - -namespace Logitar.Identity.Domain.Shared; - -/// -/// The validator used to validate custom identifiers. -/// -public class CustomIdentifierValidator : ICustomIdentifierValidator -{ - /// - /// Gets the custom identifier key validator. - /// - public IValidator KeyValidator { get; } - /// - /// Gets the custom identifier value validator. - /// - public IValidator ValueValidator { get; } - - /// - /// Initializes a new instance of the class. - /// - /// The custom identifier key validator. - /// The custom identifier value validator. - public CustomIdentifierValidator(IValidator? keyValidator = null, IValidator? valueValidator = null) - { - KeyValidator = keyValidator ?? new CustomIdentifierKeyValidator("Key"); - ValueValidator = valueValidator ?? new CustomIdentifierValueValidator("Value"); - } - - /// - /// Validates the specified custom identifier key and value. - /// An will be thrown if validation fails. - /// - /// The key of the custom identifier. - /// The value of the custom identifier. - public void ValidateAndThrow(string key, string value) - { - KeyValidator.ValidateAndThrow(key); - ValueValidator.ValidateAndThrow(value); - } -} diff --git a/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValueValidator.cs b/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValueValidator.cs deleted file mode 100644 index f7e904a..0000000 --- a/old/src/Logitar.Identity.Domain/Shared/CustomIdentifierValueValidator.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentValidation; - -namespace Logitar.Identity.Domain.Shared; - -/// -/// The validator used to validate custom identifier values. -/// See for more information. -/// -public class CustomIdentifierValueValidator : AbstractValidator -{ - /// - /// The maximum length of custom identifier values. - /// - public const int MaximumLength = byte.MaxValue; - - /// - /// Initializes a new instance of the class. - /// - /// The name of the property, used for validation. - public CustomIdentifierValueValidator(string? propertyName = null) - { - RuleFor(x => x).NotEmpty().MaximumLength(MaximumLength).WithPropertyName(propertyName); - } -} diff --git a/old/src/Logitar.Identity.Domain/Shared/FutureValidator.cs b/old/src/Logitar.Identity.Domain/Shared/FutureValidator.cs deleted file mode 100644 index c0372fd..0000000 --- a/old/src/Logitar.Identity.Domain/Shared/FutureValidator.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentValidation; - -namespace Logitar.Identity.Domain.Shared; - -/// -/// The validator used to validate future dates. -/// -public class FutureValidator : AbstractValidator -{ - /// - /// Initializes a new instance of the class. - /// - /// The validation moment, defauts to now. - public FutureValidator(DateTime? moment = null) - { - RuleFor(x => x).Must(value => value > (moment ?? DateTime.Now)) - .WithErrorCode(nameof(FutureValidator)) - .WithMessage("'{PropertyName}' must be a date and time set in the future."); - } -} diff --git a/old/src/Logitar.Identity.Domain/Shared/ICustomIdentifierValidator.cs b/old/src/Logitar.Identity.Domain/Shared/ICustomIdentifierValidator.cs deleted file mode 100644 index 4abe9e0..0000000 --- a/old/src/Logitar.Identity.Domain/Shared/ICustomIdentifierValidator.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FluentValidation; - -namespace Logitar.Identity.Domain.Shared; - -/// -/// Describes custom identifier validators. -/// -public interface ICustomIdentifierValidator -{ - /// - /// Gets the custom identifier key validator. - /// - IValidator KeyValidator { get; } - /// - /// Gets the custom identifier value validator. - /// - IValidator ValueValidator { get; } - - /// - /// Validates the specified custom identifier key and value. - /// An will be thrown if validation fails. - /// - /// The key of the custom identifier. - /// The value of the custom identifier. - void ValidateAndThrow(string key, string value); -} diff --git a/old/src/Logitar.Identity.Domain/Shared/PastValidator.cs b/old/src/Logitar.Identity.Domain/Shared/PastValidator.cs deleted file mode 100644 index fa5d3e7..0000000 --- a/old/src/Logitar.Identity.Domain/Shared/PastValidator.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentValidation; - -namespace Logitar.Identity.Domain.Shared; - -/// -/// The validator used to validate past dates. -/// -public class PastValidator : AbstractValidator -{ - /// - /// Initializes a new instance of the class. - /// - /// The validation moment, defauts to now. - public PastValidator(DateTime? moment = null) - { - RuleFor(x => x).Must(value => value < (moment ?? DateTime.Now)) - .WithErrorCode(nameof(PastValidator)) - .WithMessage("'{PropertyName}' must be a date and time set in the past."); - } -} diff --git a/old/src/Logitar.Identity.Domain/Users/UserAggregate.cs b/old/src/Logitar.Identity.Domain/Users/UserAggregate.cs index f525506..4daa5d8 100644 --- a/old/src/Logitar.Identity.Domain/Users/UserAggregate.cs +++ b/old/src/Logitar.Identity.Domain/Users/UserAggregate.cs @@ -1,7 +1,5 @@ using Logitar.EventSourcing; using Logitar.Identity.Domain.Sessions; -using Logitar.Identity.Domain.Shared; -using Logitar.Identity.Domain.Users.Events; namespace Logitar.Identity.Domain.Users;