diff --git a/CleanArchitecture.Api/Controllers/TenantController.cs b/CleanArchitecture.Api/Controllers/TenantController.cs index 8caf488..01a516b 100644 --- a/CleanArchitecture.Api/Controllers/TenantController.cs +++ b/CleanArchitecture.Api/Controllers/TenantController.cs @@ -48,7 +48,7 @@ public sealed class TenantController : ApiController return Response(tenants); } - [HttpGet("{id:guid}")] + [HttpGet("{id}")] [SwaggerOperation("Get a tenant by id")] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage))] public async Task GetTenantByIdAsync([FromRoute] Guid id) @@ -75,7 +75,7 @@ public sealed class TenantController : ApiController return Response(tenant); } - [HttpDelete("{id:guid}")] + [HttpDelete("{id}")] [SwaggerOperation("Delete an existing tenant")] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage))] public async Task DeleteTenantAsync([FromRoute] Guid id) diff --git a/CleanArchitecture.Api/Controllers/UserController.cs b/CleanArchitecture.Api/Controllers/UserController.cs index 9a0f9e3..e2c4eba 100644 --- a/CleanArchitecture.Api/Controllers/UserController.cs +++ b/CleanArchitecture.Api/Controllers/UserController.cs @@ -48,7 +48,7 @@ public sealed class UserController : ApiController return Response(users); } - [HttpGet("{id:guid}")] + [HttpGet("{id}")] [SwaggerOperation("Get a user by id")] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage))] public async Task GetUserByIdAsync([FromRoute] Guid id) @@ -75,7 +75,7 @@ public sealed class UserController : ApiController return Response(userId); } - [HttpDelete("{id:guid}")] + [HttpDelete("{id}")] [SwaggerOperation("Delete a user")] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage))] public async Task DeleteUserAsync([FromRoute] Guid id) diff --git a/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs b/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs index 60305bf..bc9d9a1 100644 --- a/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs +++ b/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs @@ -33,8 +33,6 @@ public sealed class GetUserByIdTestFixture : QueryHandlerBaseFixture "Password", UserRole.User); - var query = new[] { user }.BuildMock(); - UserRepository.GetByIdAsync(Arg.Is(y => y == ExistingUserId)).Returns(user); } diff --git a/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs b/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs index 885dcfa..7b16b5d 100644 --- a/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs +++ b/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs @@ -40,7 +40,7 @@ public sealed class GetUserByIdQueryHandlerTests _fixture.VerifyExistingNotification( nameof(GetUserByIdQuery), ErrorCodes.ObjectNotFound, - $"User with id {request.UserId} could not be found"); + $"User with id {request.Id} could not be found"); result.Should().BeNull(); } diff --git a/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQuery.cs b/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQuery.cs index cc11673..28c59c2 100644 --- a/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQuery.cs +++ b/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQuery.cs @@ -4,4 +4,4 @@ using MediatR; namespace CleanArchitecture.Application.Queries.Users.GetUserById; -public sealed record GetUserByIdQuery(Guid UserId) : IRequest; \ No newline at end of file +public sealed record GetUserByIdQuery(Guid Id) : IRequest; \ No newline at end of file diff --git a/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQueryHandler.cs b/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQueryHandler.cs index d80268a..856c29b 100644 --- a/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQueryHandler.cs +++ b/CleanArchitecture.Application/Queries/Users/GetUserById/GetUserByIdQueryHandler.cs @@ -23,14 +23,14 @@ public sealed class GetUserByIdQueryHandler : public async Task Handle(GetUserByIdQuery request, CancellationToken cancellationToken) { - var user = await _userRepository.GetByIdAsync(request.UserId); + var user = await _userRepository.GetByIdAsync(request.Id); if (user is null) { await _bus.RaiseEventAsync( new DomainNotification( nameof(GetUserByIdQuery), - $"User with id {request.UserId} could not be found", + $"User with id {request.Id} could not be found", ErrorCodes.ObjectNotFound)); return null; } diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandHandlerTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandHandlerTests.cs index b44cb19..184a9c3 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandHandlerTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandHandlerTests.cs @@ -64,7 +64,7 @@ public sealed class CreateTenantCommandHandlerTests .VerifyNoRaisedEvent() .VerifyAnyDomainNotification() .VerifyExistingNotification( - DomainErrorCodes.Tenant.TenantAlreadyExists, + DomainErrorCodes.Tenant.AlreadyExists, $"There is already a tenant with Id {command.AggregateId}"); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandValidationTests.cs index 2156932..e63b056 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/CreateTenant/CreateTenantCommandValidationTests.cs @@ -27,7 +27,7 @@ public sealed class CreateTenantCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.Tenant.TenantEmptyId, + DomainErrorCodes.Tenant.EmptyId, "Tenant id may not be empty"); } @@ -38,7 +38,7 @@ public sealed class CreateTenantCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.Tenant.TenantEmptyName, + DomainErrorCodes.Tenant.EmptyName, "Name may not be empty"); } diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/DeleteTenant/DeleteTenantCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/DeleteTenant/DeleteTenantCommandValidationTests.cs index b36e294..cb0dcb0 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/DeleteTenant/DeleteTenantCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/DeleteTenant/DeleteTenantCommandValidationTests.cs @@ -27,7 +27,7 @@ public sealed class DeleteTenantCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.Tenant.TenantEmptyId, + DomainErrorCodes.Tenant.EmptyId, "Tenant id may not be empty"); } diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/UpdateTenant/UpdateTenantCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/UpdateTenant/UpdateTenantCommandValidationTests.cs index c7c4f11..60da1b5 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/UpdateTenant/UpdateTenantCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/Tenant/UpdateTenant/UpdateTenantCommandValidationTests.cs @@ -27,7 +27,7 @@ public sealed class UpdateTenantCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.Tenant.TenantEmptyId, + DomainErrorCodes.Tenant.EmptyId, "Tenant id may not be empty"); } @@ -38,7 +38,7 @@ public sealed class UpdateTenantCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.Tenant.TenantEmptyName, + DomainErrorCodes.Tenant.EmptyName, "Name may not be empty"); } diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandHandlerTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandHandlerTests.cs index a318a0f..dad7f7e 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandHandlerTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandHandlerTests.cs @@ -57,7 +57,7 @@ public sealed class ChangePasswordCommandHandlerTests .VerifyNoRaisedEvent() .VerifyAnyDomainNotification() .VerifyExistingNotification( - DomainErrorCodes.User.UserPasswordIncorrect, + DomainErrorCodes.User.PasswordIncorrect, "The password is incorrect"); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandValidationTests.cs index b75d5f4..3ae25a5 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/ChangePassword/ChangePasswordCommandValidationTests.cs @@ -28,12 +28,12 @@ public sealed class ChangePasswordCommandValidationTests : var errors = new List { - DomainErrorCodes.User.UserEmptyPassword, - DomainErrorCodes.User.UserSpecialCharPassword, - DomainErrorCodes.User.UserNumberPassword, - DomainErrorCodes.User.UserLowercaseLetterPassword, - DomainErrorCodes.User.UserUppercaseLetterPassword, - DomainErrorCodes.User.UserShortPassword + DomainErrorCodes.User.EmptyPassword, + DomainErrorCodes.User.SpecialCharPassword, + DomainErrorCodes.User.NumberPassword, + DomainErrorCodes.User.LowercaseLetterPassword, + DomainErrorCodes.User.UppercaseLetterPassword, + DomainErrorCodes.User.ShortPassword }; ShouldHaveExpectedErrors(command, errors.ToArray()); @@ -44,7 +44,7 @@ public sealed class ChangePasswordCommandValidationTests : { var command = CreateTestCommand("z8tnayvd5FNLU9AQm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserSpecialCharPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.SpecialCharPassword); } [Fact] @@ -52,7 +52,7 @@ public sealed class ChangePasswordCommandValidationTests : { var command = CreateTestCommand("z]tnayvdFNLU:]AQm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserNumberPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.NumberPassword); } [Fact] @@ -60,7 +60,7 @@ public sealed class ChangePasswordCommandValidationTests : { var command = CreateTestCommand("Z8]TNAYVDFNLU:]AQM"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserLowercaseLetterPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.LowercaseLetterPassword); } [Fact] @@ -68,7 +68,7 @@ public sealed class ChangePasswordCommandValidationTests : { var command = CreateTestCommand("z8]tnayvd5fnlu9:]aqm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserUppercaseLetterPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.UppercaseLetterPassword); } [Fact] @@ -76,7 +76,7 @@ public sealed class ChangePasswordCommandValidationTests : { var command = CreateTestCommand("zA6{"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserShortPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.ShortPassword); } [Fact] @@ -84,7 +84,7 @@ public sealed class ChangePasswordCommandValidationTests : { var command = CreateTestCommand(string.Concat(Enumerable.Repeat("zA6{", 12), 12)); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserLongPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.LongPassword); } private static ChangePasswordCommand CreateTestCommand( diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandHandlerTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandHandlerTests.cs index 25108ee..db01af9 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandHandlerTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandHandlerTests.cs @@ -59,7 +59,7 @@ public sealed class CreateUserCommandHandlerTests .VerifyNoRaisedEvent() .VerifyAnyDomainNotification() .VerifyExistingNotification( - DomainErrorCodes.User.UserAlreadyExists, + DomainErrorCodes.User.AlreadyExists, $"There is already a user with Id {command.UserId}"); } @@ -94,7 +94,7 @@ public sealed class CreateUserCommandHandlerTests .VerifyNoRaisedEvent() .VerifyAnyDomainNotification() .VerifyExistingNotification( - DomainErrorCodes.User.UserAlreadyExists, + DomainErrorCodes.User.AlreadyExists, $"There is already a user with email {command.Email}"); } diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandValidationTests.cs index 05e3d7c..dfa64c7 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/CreateUser/CreateUserCommandValidationTests.cs @@ -30,7 +30,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmptyId, + DomainErrorCodes.User.EmptyId, "User id may not be empty"); } @@ -41,7 +41,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserInvalidEmail, + DomainErrorCodes.User.InvalidEmail, "Email is not a valid email address"); } @@ -52,7 +52,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserInvalidEmail, + DomainErrorCodes.User.InvalidEmail, "Email is not a valid email address"); } @@ -63,7 +63,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmailExceedsMaxLength, + DomainErrorCodes.User.EmailExceedsMaxLength, $"Email may not be longer than {MaxLengths.User.Email} characters"); } @@ -74,7 +74,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmptyFirstName, + DomainErrorCodes.User.EmptyFirstName, "FirstName may not be empty"); } @@ -85,7 +85,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserFirstNameExceedsMaxLength, + DomainErrorCodes.User.FirstNameExceedsMaxLength, $"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); } @@ -96,7 +96,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmptyLastName, + DomainErrorCodes.User.EmptyLastName, "LastName may not be empty"); } @@ -107,7 +107,7 @@ public sealed class CreateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserLastNameExceedsMaxLength, + DomainErrorCodes.User.LastNameExceedsMaxLength, $"LastName may not be longer than {MaxLengths.User.LastName} characters"); } @@ -118,12 +118,12 @@ public sealed class CreateUserCommandValidationTests : var errors = new List { - DomainErrorCodes.User.UserEmptyPassword, - DomainErrorCodes.User.UserSpecialCharPassword, - DomainErrorCodes.User.UserNumberPassword, - DomainErrorCodes.User.UserLowercaseLetterPassword, - DomainErrorCodes.User.UserUppercaseLetterPassword, - DomainErrorCodes.User.UserShortPassword + DomainErrorCodes.User.EmptyPassword, + DomainErrorCodes.User.SpecialCharPassword, + DomainErrorCodes.User.NumberPassword, + DomainErrorCodes.User.LowercaseLetterPassword, + DomainErrorCodes.User.UppercaseLetterPassword, + DomainErrorCodes.User.ShortPassword }; ShouldHaveExpectedErrors(command, errors.ToArray()); @@ -134,7 +134,7 @@ public sealed class CreateUserCommandValidationTests : { var command = CreateTestCommand(password: "z8tnayvd5FNLU9AQm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserSpecialCharPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.SpecialCharPassword); } [Fact] @@ -142,7 +142,7 @@ public sealed class CreateUserCommandValidationTests : { var command = CreateTestCommand(password: "z]tnayvdFNLU:]AQm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserNumberPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.NumberPassword); } [Fact] @@ -150,7 +150,7 @@ public sealed class CreateUserCommandValidationTests : { var command = CreateTestCommand(password: "Z8]TNAYVDFNLU:]AQM"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserLowercaseLetterPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.LowercaseLetterPassword); } [Fact] @@ -158,7 +158,7 @@ public sealed class CreateUserCommandValidationTests : { var command = CreateTestCommand(password: "z8]tnayvd5fnlu9:]aqm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserUppercaseLetterPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.UppercaseLetterPassword); } [Fact] @@ -166,7 +166,7 @@ public sealed class CreateUserCommandValidationTests : { var command = CreateTestCommand(password: "zA6{"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserShortPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.ShortPassword); } [Fact] @@ -174,7 +174,7 @@ public sealed class CreateUserCommandValidationTests : { var command = CreateTestCommand(password: string.Concat(Enumerable.Repeat("zA6{", 12), 12)); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserLongPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.LongPassword); } [Fact] @@ -182,7 +182,7 @@ public sealed class CreateUserCommandValidationTests : { var command = CreateTestCommand(tenantId: Guid.Empty); - ShouldHaveSingleError(command, DomainErrorCodes.Tenant.TenantEmptyId); + ShouldHaveSingleError(command, DomainErrorCodes.Tenant.EmptyId); } private static CreateUserCommand CreateTestCommand( diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/DeleteUser/DeleteUserCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/DeleteUser/DeleteUserCommandValidationTests.cs index 8ea63cf..24d3b4f 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/DeleteUser/DeleteUserCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/DeleteUser/DeleteUserCommandValidationTests.cs @@ -27,7 +27,7 @@ public sealed class DeleteUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmptyId, + DomainErrorCodes.User.EmptyId, "User id may not be empty"); } diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs index 1c26051..c9cca36 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs @@ -74,7 +74,7 @@ public sealed class LoginUserCommandHandlerTests _fixture .VerifyAnyDomainNotification() .VerifyExistingNotification( - DomainErrorCodes.User.UserPasswordIncorrect, + DomainErrorCodes.User.PasswordIncorrect, "The password is incorrect"); token.Should().BeEmpty(); diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandValidationTests.cs index 7b1ca35..300e186 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandValidationTests.cs @@ -29,7 +29,7 @@ public sealed class LoginUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserInvalidEmail, + DomainErrorCodes.User.InvalidEmail, "Email is not a valid email address"); } @@ -40,7 +40,7 @@ public sealed class LoginUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserInvalidEmail, + DomainErrorCodes.User.InvalidEmail, "Email is not a valid email address"); } @@ -51,7 +51,7 @@ public sealed class LoginUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmailExceedsMaxLength, + DomainErrorCodes.User.EmailExceedsMaxLength, $"Email may not be longer than {MaxLengths.User.Email} characters"); } @@ -62,12 +62,12 @@ public sealed class LoginUserCommandValidationTests : var errors = new List { - DomainErrorCodes.User.UserEmptyPassword, - DomainErrorCodes.User.UserSpecialCharPassword, - DomainErrorCodes.User.UserNumberPassword, - DomainErrorCodes.User.UserLowercaseLetterPassword, - DomainErrorCodes.User.UserUppercaseLetterPassword, - DomainErrorCodes.User.UserShortPassword + DomainErrorCodes.User.EmptyPassword, + DomainErrorCodes.User.SpecialCharPassword, + DomainErrorCodes.User.NumberPassword, + DomainErrorCodes.User.LowercaseLetterPassword, + DomainErrorCodes.User.UppercaseLetterPassword, + DomainErrorCodes.User.ShortPassword }; ShouldHaveExpectedErrors(command, errors.ToArray()); @@ -78,7 +78,7 @@ public sealed class LoginUserCommandValidationTests : { var command = CreateTestCommand(password: "z8tnayvd5FNLU9AQm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserSpecialCharPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.SpecialCharPassword); } [Fact] @@ -86,7 +86,7 @@ public sealed class LoginUserCommandValidationTests : { var command = CreateTestCommand(password: "z]tnayvdFNLU:]AQm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserNumberPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.NumberPassword); } [Fact] @@ -94,7 +94,7 @@ public sealed class LoginUserCommandValidationTests : { var command = CreateTestCommand(password: "Z8]TNAYVDFNLU:]AQM"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserLowercaseLetterPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.LowercaseLetterPassword); } [Fact] @@ -102,7 +102,7 @@ public sealed class LoginUserCommandValidationTests : { var command = CreateTestCommand(password: "z8]tnayvd5fnlu9:]aqm"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserUppercaseLetterPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.UppercaseLetterPassword); } [Fact] @@ -110,7 +110,7 @@ public sealed class LoginUserCommandValidationTests : { var command = CreateTestCommand(password: "zA6{"); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserShortPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.ShortPassword); } [Fact] @@ -118,7 +118,7 @@ public sealed class LoginUserCommandValidationTests : { var command = CreateTestCommand(password: string.Concat(Enumerable.Repeat("zA6{", 12), 12)); - ShouldHaveSingleError(command, DomainErrorCodes.User.UserLongPassword); + ShouldHaveSingleError(command, DomainErrorCodes.User.LongPassword); } private static LoginUserCommand CreateTestCommand( diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandHandlerTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandHandlerTests.cs index 9395f57..06bf867 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandHandlerTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandHandlerTests.cs @@ -95,7 +95,7 @@ public sealed class UpdateUserCommandHandlerTests .VerifyNoRaisedEvent() .VerifyAnyDomainNotification() .VerifyExistingNotification( - DomainErrorCodes.User.UserAlreadyExists, + DomainErrorCodes.User.AlreadyExists, $"There is already a user with email {command.Email}"); } diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandValidationTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandValidationTests.cs index 42de98f..2770de7 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandValidationTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/UpdateUser/UpdateUserCommandValidationTests.cs @@ -29,7 +29,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmptyId, + DomainErrorCodes.User.EmptyId, "User id may not be empty"); } @@ -40,7 +40,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserInvalidEmail, + DomainErrorCodes.User.InvalidEmail, "Email is not a valid email address"); } @@ -51,7 +51,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserInvalidEmail, + DomainErrorCodes.User.InvalidEmail, "Email is not a valid email address"); } @@ -62,7 +62,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmailExceedsMaxLength, + DomainErrorCodes.User.EmailExceedsMaxLength, $"Email may not be longer than {MaxLengths.User.Email} characters"); } @@ -73,7 +73,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmptyFirstName, + DomainErrorCodes.User.EmptyFirstName, "FirstName may not be empty"); } @@ -84,7 +84,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserFirstNameExceedsMaxLength, + DomainErrorCodes.User.FirstNameExceedsMaxLength, $"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); } @@ -95,7 +95,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserEmptyLastName, + DomainErrorCodes.User.EmptyLastName, "LastName may not be empty"); } @@ -106,7 +106,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.User.UserLastNameExceedsMaxLength, + DomainErrorCodes.User.LastNameExceedsMaxLength, $"LastName may not be longer than {MaxLengths.User.LastName} characters"); } @@ -117,7 +117,7 @@ public sealed class UpdateUserCommandValidationTests : ShouldHaveSingleError( command, - DomainErrorCodes.Tenant.TenantEmptyId, + DomainErrorCodes.Tenant.EmptyId, "Tenant id may not be empty"); } diff --git a/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandHandler.cs b/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandHandler.cs index 4887de8..779a1bf 100644 --- a/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandHandler.cs +++ b/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandHandler.cs @@ -52,7 +52,7 @@ public sealed class CreateTenantCommandHandler : CommandHandlerBase, new DomainNotification( request.MessageType, $"There is already a tenant with Id {request.AggregateId}", - DomainErrorCodes.Tenant.TenantAlreadyExists)); + DomainErrorCodes.Tenant.AlreadyExists)); return; } diff --git a/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandValidation.cs b/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandValidation.cs index 9ac7602..8c6b5be 100644 --- a/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandValidation.cs +++ b/CleanArchitecture.Domain/Commands/Tenants/CreateTenant/CreateTenantCommandValidation.cs @@ -16,7 +16,7 @@ public sealed class CreateTenantCommandValidation : AbstractValidator cmd.AggregateId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) + .WithErrorCode(DomainErrorCodes.Tenant.EmptyId) .WithMessage("Tenant id may not be empty"); } @@ -24,10 +24,10 @@ public sealed class CreateTenantCommandValidation : AbstractValidator cmd.Name) .NotEmpty() - .WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyName) + .WithErrorCode(DomainErrorCodes.Tenant.EmptyName) .WithMessage("Name may not be empty") .MaximumLength(MaxLengths.Tenant.Name) - .WithErrorCode(DomainErrorCodes.Tenant.TenantNameExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.Tenant.NameExceedsMaxLength) .WithMessage($"Name may not be longer than {MaxLengths.Tenant.Name} characters"); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain/Commands/Tenants/DeleteTenant/DeleteTenantCommandValidation.cs b/CleanArchitecture.Domain/Commands/Tenants/DeleteTenant/DeleteTenantCommandValidation.cs index 7b80034..1ccd058 100644 --- a/CleanArchitecture.Domain/Commands/Tenants/DeleteTenant/DeleteTenantCommandValidation.cs +++ b/CleanArchitecture.Domain/Commands/Tenants/DeleteTenant/DeleteTenantCommandValidation.cs @@ -14,7 +14,7 @@ public sealed class DeleteTenantCommandValidation : AbstractValidator cmd.AggregateId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) + .WithErrorCode(DomainErrorCodes.Tenant.EmptyId) .WithMessage("Tenant id may not be empty"); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain/Commands/Tenants/UpdateTenant/UpdateTenantCommandValidation.cs b/CleanArchitecture.Domain/Commands/Tenants/UpdateTenant/UpdateTenantCommandValidation.cs index c9abd29..bcf993c 100644 --- a/CleanArchitecture.Domain/Commands/Tenants/UpdateTenant/UpdateTenantCommandValidation.cs +++ b/CleanArchitecture.Domain/Commands/Tenants/UpdateTenant/UpdateTenantCommandValidation.cs @@ -16,7 +16,7 @@ public sealed class UpdateTenantCommandValidation : AbstractValidator cmd.AggregateId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) + .WithErrorCode(DomainErrorCodes.Tenant.EmptyId) .WithMessage("Tenant id may not be empty"); } @@ -24,10 +24,10 @@ public sealed class UpdateTenantCommandValidation : AbstractValidator cmd.Name) .NotEmpty() - .WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyName) + .WithErrorCode(DomainErrorCodes.Tenant.EmptyName) .WithMessage("Name may not be empty") .MaximumLength(MaxLengths.Tenant.Name) - .WithErrorCode(DomainErrorCodes.Tenant.TenantNameExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.Tenant.NameExceedsMaxLength) .WithMessage($"Name may not be longer than {MaxLengths.Tenant.Name} characters"); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain/Commands/Users/ChangePassword/ChangePasswordCommandHandler.cs b/CleanArchitecture.Domain/Commands/Users/ChangePassword/ChangePasswordCommandHandler.cs index 19d0616..27c6f27 100644 --- a/CleanArchitecture.Domain/Commands/Users/ChangePassword/ChangePasswordCommandHandler.cs +++ b/CleanArchitecture.Domain/Commands/Users/ChangePassword/ChangePasswordCommandHandler.cs @@ -53,7 +53,7 @@ public sealed class ChangePasswordCommandHandler : CommandHandlerBase, new DomainNotification( request.MessageType, "The password is incorrect", - DomainErrorCodes.User.UserPasswordIncorrect)); + DomainErrorCodes.User.PasswordIncorrect)); return; } diff --git a/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandHandler.cs b/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandHandler.cs index 1956f5d..7c934b4 100644 --- a/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandHandler.cs +++ b/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandHandler.cs @@ -59,7 +59,7 @@ public sealed class CreateUserCommandHandler : CommandHandlerBase, new DomainNotification( request.MessageType, $"There is already a user with Id {request.UserId}", - DomainErrorCodes.User.UserAlreadyExists)); + DomainErrorCodes.User.AlreadyExists)); return; } @@ -71,7 +71,7 @@ public sealed class CreateUserCommandHandler : CommandHandlerBase, new DomainNotification( request.MessageType, $"There is already a user with email {request.Email}", - DomainErrorCodes.User.UserAlreadyExists)); + DomainErrorCodes.User.AlreadyExists)); return; } diff --git a/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandValidation.cs b/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandValidation.cs index 371bf60..ca884c7 100644 --- a/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandValidation.cs +++ b/CleanArchitecture.Domain/Commands/Users/CreateUser/CreateUserCommandValidation.cs @@ -21,7 +21,7 @@ public sealed class CreateUserCommandValidation : AbstractValidator cmd.UserId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.User.UserEmptyId) + .WithErrorCode(DomainErrorCodes.User.EmptyId) .WithMessage("User id may not be empty"); } @@ -29,7 +29,7 @@ public sealed class CreateUserCommandValidation : AbstractValidator cmd.TenantId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) + .WithErrorCode(DomainErrorCodes.Tenant.EmptyId) .WithMessage("Tenant id may not be empty"); } @@ -37,10 +37,10 @@ public sealed class CreateUserCommandValidation : AbstractValidator cmd.Email) .EmailAddress() - .WithErrorCode(DomainErrorCodes.User.UserInvalidEmail) + .WithErrorCode(DomainErrorCodes.User.InvalidEmail) .WithMessage("Email is not a valid email address") .MaximumLength(MaxLengths.User.Email) - .WithErrorCode(DomainErrorCodes.User.UserEmailExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.User.EmailExceedsMaxLength) .WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters"); } @@ -48,10 +48,10 @@ public sealed class CreateUserCommandValidation : AbstractValidator cmd.FirstName) .NotEmpty() - .WithErrorCode(DomainErrorCodes.User.UserEmptyFirstName) + .WithErrorCode(DomainErrorCodes.User.EmptyFirstName) .WithMessage("FirstName may not be empty") .MaximumLength(MaxLengths.User.FirstName) - .WithErrorCode(DomainErrorCodes.User.UserFirstNameExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.User.FirstNameExceedsMaxLength) .WithMessage($"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); } @@ -59,10 +59,10 @@ public sealed class CreateUserCommandValidation : AbstractValidator cmd.LastName) .NotEmpty() - .WithErrorCode(DomainErrorCodes.User.UserEmptyLastName) + .WithErrorCode(DomainErrorCodes.User.EmptyLastName) .WithMessage("LastName may not be empty") .MaximumLength(MaxLengths.User.LastName) - .WithErrorCode(DomainErrorCodes.User.UserLastNameExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.User.LastNameExceedsMaxLength) .WithMessage($"LastName may not be longer than {MaxLengths.User.LastName} characters"); } diff --git a/CleanArchitecture.Domain/Commands/Users/DeleteUser/DeleteUserCommandValidation.cs b/CleanArchitecture.Domain/Commands/Users/DeleteUser/DeleteUserCommandValidation.cs index 7ca78ad..170fc15 100644 --- a/CleanArchitecture.Domain/Commands/Users/DeleteUser/DeleteUserCommandValidation.cs +++ b/CleanArchitecture.Domain/Commands/Users/DeleteUser/DeleteUserCommandValidation.cs @@ -14,7 +14,7 @@ public sealed class DeleteUserCommandValidation : AbstractValidator cmd.UserId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.User.UserEmptyId) + .WithErrorCode(DomainErrorCodes.User.EmptyId) .WithMessage("User id may not be empty"); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs b/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs index 118a211..c95b1e8 100644 --- a/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs +++ b/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs @@ -64,7 +64,7 @@ public sealed class LoginUserCommandHandler : CommandHandlerBase, new DomainNotification( request.MessageType, "The password is incorrect", - DomainErrorCodes.User.UserPasswordIncorrect)); + DomainErrorCodes.User.PasswordIncorrect)); return ""; } diff --git a/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandValidation.cs b/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandValidation.cs index 488fca0..b64ad9e 100644 --- a/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandValidation.cs +++ b/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandValidation.cs @@ -17,10 +17,10 @@ public sealed class LoginUserCommandValidation : AbstractValidator cmd.Email) .EmailAddress() - .WithErrorCode(DomainErrorCodes.User.UserInvalidEmail) + .WithErrorCode(DomainErrorCodes.User.InvalidEmail) .WithMessage("Email is not a valid email address") .MaximumLength(MaxLengths.User.Email) - .WithErrorCode(DomainErrorCodes.User.UserEmailExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.User.EmailExceedsMaxLength) .WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters"); } diff --git a/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandHandler.cs b/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandHandler.cs index 518ea37..506ab34 100644 --- a/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandHandler.cs +++ b/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandHandler.cs @@ -70,7 +70,7 @@ public sealed class UpdateUserCommandHandler : CommandHandlerBase, new DomainNotification( request.MessageType, $"There is already a user with email {request.Email}", - DomainErrorCodes.User.UserAlreadyExists)); + DomainErrorCodes.User.AlreadyExists)); return; } } diff --git a/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandValidation.cs b/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandValidation.cs index 9380fb2..e48bfaa 100644 --- a/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandValidation.cs +++ b/CleanArchitecture.Domain/Commands/Users/UpdateUser/UpdateUserCommandValidation.cs @@ -20,7 +20,7 @@ public sealed class UpdateUserCommandValidation : AbstractValidator cmd.UserId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.User.UserEmptyId) + .WithErrorCode(DomainErrorCodes.User.EmptyId) .WithMessage("User id may not be empty"); } @@ -28,7 +28,7 @@ public sealed class UpdateUserCommandValidation : AbstractValidator cmd.TenantId) .NotEmpty() - .WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) + .WithErrorCode(DomainErrorCodes.Tenant.EmptyId) .WithMessage("Tenant id may not be empty"); } @@ -36,10 +36,10 @@ public sealed class UpdateUserCommandValidation : AbstractValidator cmd.Email) .EmailAddress() - .WithErrorCode(DomainErrorCodes.User.UserInvalidEmail) + .WithErrorCode(DomainErrorCodes.User.InvalidEmail) .WithMessage("Email is not a valid email address") .MaximumLength(MaxLengths.User.Email) - .WithErrorCode(DomainErrorCodes.User.UserEmailExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.User.EmailExceedsMaxLength) .WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters"); } @@ -47,10 +47,10 @@ public sealed class UpdateUserCommandValidation : AbstractValidator cmd.FirstName) .NotEmpty() - .WithErrorCode(DomainErrorCodes.User.UserEmptyFirstName) + .WithErrorCode(DomainErrorCodes.User.EmptyFirstName) .WithMessage("FirstName may not be empty") .MaximumLength(MaxLengths.User.FirstName) - .WithErrorCode(DomainErrorCodes.User.UserFirstNameExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.User.FirstNameExceedsMaxLength) .WithMessage($"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); } @@ -58,10 +58,10 @@ public sealed class UpdateUserCommandValidation : AbstractValidator cmd.LastName) .NotEmpty() - .WithErrorCode(DomainErrorCodes.User.UserEmptyLastName) + .WithErrorCode(DomainErrorCodes.User.EmptyLastName) .WithMessage("LastName may not be empty") .MaximumLength(MaxLengths.User.LastName) - .WithErrorCode(DomainErrorCodes.User.UserLastNameExceedsMaxLength) + .WithErrorCode(DomainErrorCodes.User.LastNameExceedsMaxLength) .WithMessage($"LastName may not be longer than {MaxLengths.User.LastName} characters"); } @@ -69,7 +69,7 @@ public sealed class UpdateUserCommandValidation : AbstractValidator cmd.Role) .IsInEnum() - .WithErrorCode(DomainErrorCodes.User.UserInvalidRole) + .WithErrorCode(DomainErrorCodes.User.InvalidRole) .WithMessage("Role is not a valid role"); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain/Errors/DomainErrorCodes.cs b/CleanArchitecture.Domain/Errors/DomainErrorCodes.cs index 76977e4..7c0c7e9 100644 --- a/CleanArchitecture.Domain/Errors/DomainErrorCodes.cs +++ b/CleanArchitecture.Domain/Errors/DomainErrorCodes.cs @@ -5,37 +5,37 @@ public static class DomainErrorCodes public static class User { // User Validation - public const string UserEmptyId = "USER_EMPTY_ID"; - public const string UserEmptyFirstName = "USER_EMPTY_FIRST_NAME"; - public const string UserEmptyLastName = "USER_EMPTY_LAST_NAME"; - public const string UserEmailExceedsMaxLength = "USER_EMAIL_EXCEEDS_MAX_LENGTH"; - public const string UserFirstNameExceedsMaxLength = "USER_FIRST_NAME_EXCEEDS_MAX_LENGTH"; - public const string UserLastNameExceedsMaxLength = "USER_LAST_NAME_EXCEEDS_MAX_LENGTH"; - public const string UserInvalidEmail = "USER_INVALID_EMAIL"; - public const string UserInvalidRole = "USER_INVALID_ROLE"; + public const string EmptyId = "USER_EMPTY_ID"; + public const string EmptyFirstName = "USER_EMPTY_FIRST_NAME"; + public const string EmptyLastName = "USER_EMPTY_LAST_NAME"; + public const string EmailExceedsMaxLength = "USER_EMAIL_EXCEEDS_MAX_LENGTH"; + public const string FirstNameExceedsMaxLength = "USER_FIRST_NAME_EXCEEDS_MAX_LENGTH"; + public const string LastNameExceedsMaxLength = "USER_LAST_NAME_EXCEEDS_MAX_LENGTH"; + public const string InvalidEmail = "USER_INVALID_EMAIL"; + public const string InvalidRole = "USER_INVALID_ROLE"; // User Password Validation - public const string UserEmptyPassword = "USER_PASSWORD_MAY_NOT_BE_EMPTY"; - public const string UserShortPassword = "USER_PASSWORD_MAY_NOT_BE_SHORTER_THAN_6_CHARACTERS"; - public const string UserLongPassword = "USER_PASSWORD_MAY_NOT_BE_LONGER_THAN_50_CHARACTERS"; - public const string UserUppercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_UPPERCASE_LETTER"; - public const string UserLowercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_LOWERCASE_LETTER"; - public const string UserNumberPassword = "USER_PASSWORD_MUST_CONTAIN_A_NUMBER"; - public const string UserSpecialCharPassword = "USER_PASSWORD_MUST_CONTAIN_A_SPECIAL_CHARACTER"; + public const string EmptyPassword = "USER_PASSWORD_MAY_NOT_BE_EMPTY"; + public const string ShortPassword = "USER_PASSWORD_MAY_NOT_BE_SHORTER_THAN_6_CHARACTERS"; + public const string LongPassword = "USER_PASSWORD_MAY_NOT_BE_LONGER_THAN_50_CHARACTERS"; + public const string UppercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_UPPERCASE_LETTER"; + public const string LowercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_LOWERCASE_LETTER"; + public const string NumberPassword = "USER_PASSWORD_MUST_CONTAIN_A_NUMBER"; + public const string SpecialCharPassword = "USER_PASSWORD_MUST_CONTAIN_A_SPECIAL_CHARACTER"; // General - public const string UserAlreadyExists = "USER_ALREADY_EXISTS"; - public const string UserPasswordIncorrect = "USER_PASSWORD_INCORRECT"; + public const string AlreadyExists = "USER_ALREADY_EXISTS"; + public const string PasswordIncorrect = "USER_PASSWORD_INCORRECT"; } public static class Tenant { // Tenant Validation - public const string TenantEmptyId = "TENANT_EMPTY_ID"; - public const string TenantEmptyName = "TENANT_EMPTY_NAME"; - public const string TenantNameExceedsMaxLength = "TENANT_NAME_EXCEEDS_MAX_LENGTH"; + public const string EmptyId = "TENANT_EMPTY_ID"; + public const string EmptyName = "TENANT_EMPTY_NAME"; + public const string NameExceedsMaxLength = "TENANT_NAME_EXCEEDS_MAX_LENGTH"; // General - public const string TenantAlreadyExists = "TENANT_ALREADY_EXISTS"; + public const string AlreadyExists = "TENANT_ALREADY_EXISTS"; } } \ No newline at end of file diff --git a/CleanArchitecture.Domain/Extensions/Validation/CustomValidator.cs b/CleanArchitecture.Domain/Extensions/Validation/CustomValidator.cs index dea14c7..cae441a 100644 --- a/CleanArchitecture.Domain/Extensions/Validation/CustomValidator.cs +++ b/CleanArchitecture.Domain/Extensions/Validation/CustomValidator.cs @@ -23,13 +23,13 @@ public static partial class CustomValidator int maxLength = 50) { var options = ruleBuilder - .NotEmpty().WithErrorCode(DomainErrorCodes.User.UserEmptyPassword) - .MinimumLength(minLength).WithErrorCode(DomainErrorCodes.User.UserShortPassword) - .MaximumLength(maxLength).WithErrorCode(DomainErrorCodes.User.UserLongPassword) - .Matches("[A-Z]").WithErrorCode(DomainErrorCodes.User.UserUppercaseLetterPassword) - .Matches("[a-z]").WithErrorCode(DomainErrorCodes.User.UserLowercaseLetterPassword) - .Matches("[0-9]").WithErrorCode(DomainErrorCodes.User.UserNumberPassword) - .Matches("[^a-zA-Z0-9]").WithErrorCode(DomainErrorCodes.User.UserSpecialCharPassword); + .NotEmpty().WithErrorCode(DomainErrorCodes.User.EmptyPassword) + .MinimumLength(minLength).WithErrorCode(DomainErrorCodes.User.ShortPassword) + .MaximumLength(maxLength).WithErrorCode(DomainErrorCodes.User.LongPassword) + .Matches("[A-Z]").WithErrorCode(DomainErrorCodes.User.UppercaseLetterPassword) + .Matches("[a-z]").WithErrorCode(DomainErrorCodes.User.LowercaseLetterPassword) + .Matches("[0-9]").WithErrorCode(DomainErrorCodes.User.NumberPassword) + .Matches("[^a-zA-Z0-9]").WithErrorCode(DomainErrorCodes.User.SpecialCharPassword); return options; }