0
0
mirror of https://github.com/alex289/CleanArchitecture.git synced 2025-06-30 02:31:08 +00:00

feat: Rename error codes

This commit is contained in:
alex289 2023-11-25 16:09:15 +01:00
parent 463121f3dc
commit 12659a138d
No known key found for this signature in database
GPG Key ID: 573F77CD2D87F863
33 changed files with 138 additions and 140 deletions

View File

@ -48,7 +48,7 @@ public sealed class TenantController : ApiController
return Response(tenants); return Response(tenants);
} }
[HttpGet("{id:guid}")] [HttpGet("{id}")]
[SwaggerOperation("Get a tenant by id")] [SwaggerOperation("Get a tenant by id")]
[SwaggerResponse(200, "Request successful", typeof(ResponseMessage<TenantViewModel>))] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage<TenantViewModel>))]
public async Task<IActionResult> GetTenantByIdAsync([FromRoute] Guid id) public async Task<IActionResult> GetTenantByIdAsync([FromRoute] Guid id)
@ -75,7 +75,7 @@ public sealed class TenantController : ApiController
return Response(tenant); return Response(tenant);
} }
[HttpDelete("{id:guid}")] [HttpDelete("{id}")]
[SwaggerOperation("Delete an existing tenant")] [SwaggerOperation("Delete an existing tenant")]
[SwaggerResponse(200, "Request successful", typeof(ResponseMessage<Guid>))] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage<Guid>))]
public async Task<IActionResult> DeleteTenantAsync([FromRoute] Guid id) public async Task<IActionResult> DeleteTenantAsync([FromRoute] Guid id)

View File

@ -48,7 +48,7 @@ public sealed class UserController : ApiController
return Response(users); return Response(users);
} }
[HttpGet("{id:guid}")] [HttpGet("{id}")]
[SwaggerOperation("Get a user by id")] [SwaggerOperation("Get a user by id")]
[SwaggerResponse(200, "Request successful", typeof(ResponseMessage<UserViewModel>))] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage<UserViewModel>))]
public async Task<IActionResult> GetUserByIdAsync([FromRoute] Guid id) public async Task<IActionResult> GetUserByIdAsync([FromRoute] Guid id)
@ -75,7 +75,7 @@ public sealed class UserController : ApiController
return Response(userId); return Response(userId);
} }
[HttpDelete("{id:guid}")] [HttpDelete("{id}")]
[SwaggerOperation("Delete a user")] [SwaggerOperation("Delete a user")]
[SwaggerResponse(200, "Request successful", typeof(ResponseMessage<Guid>))] [SwaggerResponse(200, "Request successful", typeof(ResponseMessage<Guid>))]
public async Task<IActionResult> DeleteUserAsync([FromRoute] Guid id) public async Task<IActionResult> DeleteUserAsync([FromRoute] Guid id)

View File

@ -33,8 +33,6 @@ public sealed class GetUserByIdTestFixture : QueryHandlerBaseFixture
"Password", "Password",
UserRole.User); UserRole.User);
var query = new[] { user }.BuildMock();
UserRepository.GetByIdAsync(Arg.Is<Guid>(y => y == ExistingUserId)).Returns(user); UserRepository.GetByIdAsync(Arg.Is<Guid>(y => y == ExistingUserId)).Returns(user);
} }

View File

@ -40,7 +40,7 @@ public sealed class GetUserByIdQueryHandlerTests
_fixture.VerifyExistingNotification( _fixture.VerifyExistingNotification(
nameof(GetUserByIdQuery), nameof(GetUserByIdQuery),
ErrorCodes.ObjectNotFound, ErrorCodes.ObjectNotFound,
$"User with id {request.UserId} could not be found"); $"User with id {request.Id} could not be found");
result.Should().BeNull(); result.Should().BeNull();
} }

View File

@ -4,4 +4,4 @@ using MediatR;
namespace CleanArchitecture.Application.Queries.Users.GetUserById; namespace CleanArchitecture.Application.Queries.Users.GetUserById;
public sealed record GetUserByIdQuery(Guid UserId) : IRequest<UserViewModel?>; public sealed record GetUserByIdQuery(Guid Id) : IRequest<UserViewModel?>;

View File

@ -23,14 +23,14 @@ public sealed class GetUserByIdQueryHandler :
public async Task<UserViewModel?> Handle(GetUserByIdQuery request, CancellationToken cancellationToken) public async Task<UserViewModel?> Handle(GetUserByIdQuery request, CancellationToken cancellationToken)
{ {
var user = await _userRepository.GetByIdAsync(request.UserId); var user = await _userRepository.GetByIdAsync(request.Id);
if (user is null) if (user is null)
{ {
await _bus.RaiseEventAsync( await _bus.RaiseEventAsync(
new DomainNotification( new DomainNotification(
nameof(GetUserByIdQuery), nameof(GetUserByIdQuery),
$"User with id {request.UserId} could not be found", $"User with id {request.Id} could not be found",
ErrorCodes.ObjectNotFound)); ErrorCodes.ObjectNotFound));
return null; return null;
} }

View File

@ -64,7 +64,7 @@ public sealed class CreateTenantCommandHandlerTests
.VerifyNoRaisedEvent<TenantCreatedEvent>() .VerifyNoRaisedEvent<TenantCreatedEvent>()
.VerifyAnyDomainNotification() .VerifyAnyDomainNotification()
.VerifyExistingNotification( .VerifyExistingNotification(
DomainErrorCodes.Tenant.TenantAlreadyExists, DomainErrorCodes.Tenant.AlreadyExists,
$"There is already a tenant with Id {command.AggregateId}"); $"There is already a tenant with Id {command.AggregateId}");
} }
} }

View File

@ -27,7 +27,7 @@ public sealed class CreateTenantCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.Tenant.TenantEmptyId, DomainErrorCodes.Tenant.EmptyId,
"Tenant id may not be empty"); "Tenant id may not be empty");
} }
@ -38,7 +38,7 @@ public sealed class CreateTenantCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.Tenant.TenantEmptyName, DomainErrorCodes.Tenant.EmptyName,
"Name may not be empty"); "Name may not be empty");
} }

View File

@ -27,7 +27,7 @@ public sealed class DeleteTenantCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.Tenant.TenantEmptyId, DomainErrorCodes.Tenant.EmptyId,
"Tenant id may not be empty"); "Tenant id may not be empty");
} }

View File

@ -27,7 +27,7 @@ public sealed class UpdateTenantCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.Tenant.TenantEmptyId, DomainErrorCodes.Tenant.EmptyId,
"Tenant id may not be empty"); "Tenant id may not be empty");
} }
@ -38,7 +38,7 @@ public sealed class UpdateTenantCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.Tenant.TenantEmptyName, DomainErrorCodes.Tenant.EmptyName,
"Name may not be empty"); "Name may not be empty");
} }

View File

@ -57,7 +57,7 @@ public sealed class ChangePasswordCommandHandlerTests
.VerifyNoRaisedEvent<UserUpdatedEvent>() .VerifyNoRaisedEvent<UserUpdatedEvent>()
.VerifyAnyDomainNotification() .VerifyAnyDomainNotification()
.VerifyExistingNotification( .VerifyExistingNotification(
DomainErrorCodes.User.UserPasswordIncorrect, DomainErrorCodes.User.PasswordIncorrect,
"The password is incorrect"); "The password is incorrect");
} }
} }

View File

@ -28,12 +28,12 @@ public sealed class ChangePasswordCommandValidationTests :
var errors = new List<string> var errors = new List<string>
{ {
DomainErrorCodes.User.UserEmptyPassword, DomainErrorCodes.User.EmptyPassword,
DomainErrorCodes.User.UserSpecialCharPassword, DomainErrorCodes.User.SpecialCharPassword,
DomainErrorCodes.User.UserNumberPassword, DomainErrorCodes.User.NumberPassword,
DomainErrorCodes.User.UserLowercaseLetterPassword, DomainErrorCodes.User.LowercaseLetterPassword,
DomainErrorCodes.User.UserUppercaseLetterPassword, DomainErrorCodes.User.UppercaseLetterPassword,
DomainErrorCodes.User.UserShortPassword DomainErrorCodes.User.ShortPassword
}; };
ShouldHaveExpectedErrors(command, errors.ToArray()); ShouldHaveExpectedErrors(command, errors.ToArray());
@ -44,7 +44,7 @@ public sealed class ChangePasswordCommandValidationTests :
{ {
var command = CreateTestCommand("z8tnayvd5FNLU9AQm"); var command = CreateTestCommand("z8tnayvd5FNLU9AQm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserSpecialCharPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.SpecialCharPassword);
} }
[Fact] [Fact]
@ -52,7 +52,7 @@ public sealed class ChangePasswordCommandValidationTests :
{ {
var command = CreateTestCommand("z]tnayvdFNLU:]AQm"); var command = CreateTestCommand("z]tnayvdFNLU:]AQm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserNumberPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.NumberPassword);
} }
[Fact] [Fact]
@ -60,7 +60,7 @@ public sealed class ChangePasswordCommandValidationTests :
{ {
var command = CreateTestCommand("Z8]TNAYVDFNLU:]AQM"); var command = CreateTestCommand("Z8]TNAYVDFNLU:]AQM");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserLowercaseLetterPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.LowercaseLetterPassword);
} }
[Fact] [Fact]
@ -68,7 +68,7 @@ public sealed class ChangePasswordCommandValidationTests :
{ {
var command = CreateTestCommand("z8]tnayvd5fnlu9:]aqm"); var command = CreateTestCommand("z8]tnayvd5fnlu9:]aqm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserUppercaseLetterPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.UppercaseLetterPassword);
} }
[Fact] [Fact]
@ -76,7 +76,7 @@ public sealed class ChangePasswordCommandValidationTests :
{ {
var command = CreateTestCommand("zA6{"); var command = CreateTestCommand("zA6{");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserShortPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.ShortPassword);
} }
[Fact] [Fact]
@ -84,7 +84,7 @@ public sealed class ChangePasswordCommandValidationTests :
{ {
var command = CreateTestCommand(string.Concat(Enumerable.Repeat("zA6{", 12), 12)); var command = CreateTestCommand(string.Concat(Enumerable.Repeat("zA6{", 12), 12));
ShouldHaveSingleError(command, DomainErrorCodes.User.UserLongPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.LongPassword);
} }
private static ChangePasswordCommand CreateTestCommand( private static ChangePasswordCommand CreateTestCommand(

View File

@ -59,7 +59,7 @@ public sealed class CreateUserCommandHandlerTests
.VerifyNoRaisedEvent<UserCreatedEvent>() .VerifyNoRaisedEvent<UserCreatedEvent>()
.VerifyAnyDomainNotification() .VerifyAnyDomainNotification()
.VerifyExistingNotification( .VerifyExistingNotification(
DomainErrorCodes.User.UserAlreadyExists, DomainErrorCodes.User.AlreadyExists,
$"There is already a user with Id {command.UserId}"); $"There is already a user with Id {command.UserId}");
} }
@ -94,7 +94,7 @@ public sealed class CreateUserCommandHandlerTests
.VerifyNoRaisedEvent<UserCreatedEvent>() .VerifyNoRaisedEvent<UserCreatedEvent>()
.VerifyAnyDomainNotification() .VerifyAnyDomainNotification()
.VerifyExistingNotification( .VerifyExistingNotification(
DomainErrorCodes.User.UserAlreadyExists, DomainErrorCodes.User.AlreadyExists,
$"There is already a user with email {command.Email}"); $"There is already a user with email {command.Email}");
} }

View File

@ -30,7 +30,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmptyId, DomainErrorCodes.User.EmptyId,
"User id may not be empty"); "User id may not be empty");
} }
@ -41,7 +41,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserInvalidEmail, DomainErrorCodes.User.InvalidEmail,
"Email is not a valid email address"); "Email is not a valid email address");
} }
@ -52,7 +52,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserInvalidEmail, DomainErrorCodes.User.InvalidEmail,
"Email is not a valid email address"); "Email is not a valid email address");
} }
@ -63,7 +63,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmailExceedsMaxLength, DomainErrorCodes.User.EmailExceedsMaxLength,
$"Email may not be longer than {MaxLengths.User.Email} characters"); $"Email may not be longer than {MaxLengths.User.Email} characters");
} }
@ -74,7 +74,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmptyFirstName, DomainErrorCodes.User.EmptyFirstName,
"FirstName may not be empty"); "FirstName may not be empty");
} }
@ -85,7 +85,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserFirstNameExceedsMaxLength, DomainErrorCodes.User.FirstNameExceedsMaxLength,
$"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); $"FirstName may not be longer than {MaxLengths.User.FirstName} characters");
} }
@ -96,7 +96,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmptyLastName, DomainErrorCodes.User.EmptyLastName,
"LastName may not be empty"); "LastName may not be empty");
} }
@ -107,7 +107,7 @@ public sealed class CreateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserLastNameExceedsMaxLength, DomainErrorCodes.User.LastNameExceedsMaxLength,
$"LastName may not be longer than {MaxLengths.User.LastName} characters"); $"LastName may not be longer than {MaxLengths.User.LastName} characters");
} }
@ -118,12 +118,12 @@ public sealed class CreateUserCommandValidationTests :
var errors = new List<string> var errors = new List<string>
{ {
DomainErrorCodes.User.UserEmptyPassword, DomainErrorCodes.User.EmptyPassword,
DomainErrorCodes.User.UserSpecialCharPassword, DomainErrorCodes.User.SpecialCharPassword,
DomainErrorCodes.User.UserNumberPassword, DomainErrorCodes.User.NumberPassword,
DomainErrorCodes.User.UserLowercaseLetterPassword, DomainErrorCodes.User.LowercaseLetterPassword,
DomainErrorCodes.User.UserUppercaseLetterPassword, DomainErrorCodes.User.UppercaseLetterPassword,
DomainErrorCodes.User.UserShortPassword DomainErrorCodes.User.ShortPassword
}; };
ShouldHaveExpectedErrors(command, errors.ToArray()); ShouldHaveExpectedErrors(command, errors.ToArray());
@ -134,7 +134,7 @@ public sealed class CreateUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "z8tnayvd5FNLU9AQm"); var command = CreateTestCommand(password: "z8tnayvd5FNLU9AQm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserSpecialCharPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.SpecialCharPassword);
} }
[Fact] [Fact]
@ -142,7 +142,7 @@ public sealed class CreateUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "z]tnayvdFNLU:]AQm"); var command = CreateTestCommand(password: "z]tnayvdFNLU:]AQm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserNumberPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.NumberPassword);
} }
[Fact] [Fact]
@ -150,7 +150,7 @@ public sealed class CreateUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "Z8]TNAYVDFNLU:]AQM"); var command = CreateTestCommand(password: "Z8]TNAYVDFNLU:]AQM");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserLowercaseLetterPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.LowercaseLetterPassword);
} }
[Fact] [Fact]
@ -158,7 +158,7 @@ public sealed class CreateUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "z8]tnayvd5fnlu9:]aqm"); var command = CreateTestCommand(password: "z8]tnayvd5fnlu9:]aqm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserUppercaseLetterPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.UppercaseLetterPassword);
} }
[Fact] [Fact]
@ -166,7 +166,7 @@ public sealed class CreateUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "zA6{"); var command = CreateTestCommand(password: "zA6{");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserShortPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.ShortPassword);
} }
[Fact] [Fact]
@ -174,7 +174,7 @@ public sealed class CreateUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: string.Concat(Enumerable.Repeat("zA6{", 12), 12)); var command = CreateTestCommand(password: string.Concat(Enumerable.Repeat("zA6{", 12), 12));
ShouldHaveSingleError(command, DomainErrorCodes.User.UserLongPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.LongPassword);
} }
[Fact] [Fact]
@ -182,7 +182,7 @@ public sealed class CreateUserCommandValidationTests :
{ {
var command = CreateTestCommand(tenantId: Guid.Empty); var command = CreateTestCommand(tenantId: Guid.Empty);
ShouldHaveSingleError(command, DomainErrorCodes.Tenant.TenantEmptyId); ShouldHaveSingleError(command, DomainErrorCodes.Tenant.EmptyId);
} }
private static CreateUserCommand CreateTestCommand( private static CreateUserCommand CreateTestCommand(

View File

@ -27,7 +27,7 @@ public sealed class DeleteUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmptyId, DomainErrorCodes.User.EmptyId,
"User id may not be empty"); "User id may not be empty");
} }

View File

@ -74,7 +74,7 @@ public sealed class LoginUserCommandHandlerTests
_fixture _fixture
.VerifyAnyDomainNotification() .VerifyAnyDomainNotification()
.VerifyExistingNotification( .VerifyExistingNotification(
DomainErrorCodes.User.UserPasswordIncorrect, DomainErrorCodes.User.PasswordIncorrect,
"The password is incorrect"); "The password is incorrect");
token.Should().BeEmpty(); token.Should().BeEmpty();

View File

@ -29,7 +29,7 @@ public sealed class LoginUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserInvalidEmail, DomainErrorCodes.User.InvalidEmail,
"Email is not a valid email address"); "Email is not a valid email address");
} }
@ -40,7 +40,7 @@ public sealed class LoginUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserInvalidEmail, DomainErrorCodes.User.InvalidEmail,
"Email is not a valid email address"); "Email is not a valid email address");
} }
@ -51,7 +51,7 @@ public sealed class LoginUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmailExceedsMaxLength, DomainErrorCodes.User.EmailExceedsMaxLength,
$"Email may not be longer than {MaxLengths.User.Email} characters"); $"Email may not be longer than {MaxLengths.User.Email} characters");
} }
@ -62,12 +62,12 @@ public sealed class LoginUserCommandValidationTests :
var errors = new List<string> var errors = new List<string>
{ {
DomainErrorCodes.User.UserEmptyPassword, DomainErrorCodes.User.EmptyPassword,
DomainErrorCodes.User.UserSpecialCharPassword, DomainErrorCodes.User.SpecialCharPassword,
DomainErrorCodes.User.UserNumberPassword, DomainErrorCodes.User.NumberPassword,
DomainErrorCodes.User.UserLowercaseLetterPassword, DomainErrorCodes.User.LowercaseLetterPassword,
DomainErrorCodes.User.UserUppercaseLetterPassword, DomainErrorCodes.User.UppercaseLetterPassword,
DomainErrorCodes.User.UserShortPassword DomainErrorCodes.User.ShortPassword
}; };
ShouldHaveExpectedErrors(command, errors.ToArray()); ShouldHaveExpectedErrors(command, errors.ToArray());
@ -78,7 +78,7 @@ public sealed class LoginUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "z8tnayvd5FNLU9AQm"); var command = CreateTestCommand(password: "z8tnayvd5FNLU9AQm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserSpecialCharPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.SpecialCharPassword);
} }
[Fact] [Fact]
@ -86,7 +86,7 @@ public sealed class LoginUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "z]tnayvdFNLU:]AQm"); var command = CreateTestCommand(password: "z]tnayvdFNLU:]AQm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserNumberPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.NumberPassword);
} }
[Fact] [Fact]
@ -94,7 +94,7 @@ public sealed class LoginUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "Z8]TNAYVDFNLU:]AQM"); var command = CreateTestCommand(password: "Z8]TNAYVDFNLU:]AQM");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserLowercaseLetterPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.LowercaseLetterPassword);
} }
[Fact] [Fact]
@ -102,7 +102,7 @@ public sealed class LoginUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "z8]tnayvd5fnlu9:]aqm"); var command = CreateTestCommand(password: "z8]tnayvd5fnlu9:]aqm");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserUppercaseLetterPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.UppercaseLetterPassword);
} }
[Fact] [Fact]
@ -110,7 +110,7 @@ public sealed class LoginUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: "zA6{"); var command = CreateTestCommand(password: "zA6{");
ShouldHaveSingleError(command, DomainErrorCodes.User.UserShortPassword); ShouldHaveSingleError(command, DomainErrorCodes.User.ShortPassword);
} }
[Fact] [Fact]
@ -118,7 +118,7 @@ public sealed class LoginUserCommandValidationTests :
{ {
var command = CreateTestCommand(password: string.Concat(Enumerable.Repeat("zA6{", 12), 12)); 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( private static LoginUserCommand CreateTestCommand(

View File

@ -95,7 +95,7 @@ public sealed class UpdateUserCommandHandlerTests
.VerifyNoRaisedEvent<UserUpdatedEvent>() .VerifyNoRaisedEvent<UserUpdatedEvent>()
.VerifyAnyDomainNotification() .VerifyAnyDomainNotification()
.VerifyExistingNotification( .VerifyExistingNotification(
DomainErrorCodes.User.UserAlreadyExists, DomainErrorCodes.User.AlreadyExists,
$"There is already a user with email {command.Email}"); $"There is already a user with email {command.Email}");
} }

View File

@ -29,7 +29,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmptyId, DomainErrorCodes.User.EmptyId,
"User id may not be empty"); "User id may not be empty");
} }
@ -40,7 +40,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserInvalidEmail, DomainErrorCodes.User.InvalidEmail,
"Email is not a valid email address"); "Email is not a valid email address");
} }
@ -51,7 +51,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserInvalidEmail, DomainErrorCodes.User.InvalidEmail,
"Email is not a valid email address"); "Email is not a valid email address");
} }
@ -62,7 +62,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmailExceedsMaxLength, DomainErrorCodes.User.EmailExceedsMaxLength,
$"Email may not be longer than {MaxLengths.User.Email} characters"); $"Email may not be longer than {MaxLengths.User.Email} characters");
} }
@ -73,7 +73,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmptyFirstName, DomainErrorCodes.User.EmptyFirstName,
"FirstName may not be empty"); "FirstName may not be empty");
} }
@ -84,7 +84,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserFirstNameExceedsMaxLength, DomainErrorCodes.User.FirstNameExceedsMaxLength,
$"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); $"FirstName may not be longer than {MaxLengths.User.FirstName} characters");
} }
@ -95,7 +95,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserEmptyLastName, DomainErrorCodes.User.EmptyLastName,
"LastName may not be empty"); "LastName may not be empty");
} }
@ -106,7 +106,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.User.UserLastNameExceedsMaxLength, DomainErrorCodes.User.LastNameExceedsMaxLength,
$"LastName may not be longer than {MaxLengths.User.LastName} characters"); $"LastName may not be longer than {MaxLengths.User.LastName} characters");
} }
@ -117,7 +117,7 @@ public sealed class UpdateUserCommandValidationTests :
ShouldHaveSingleError( ShouldHaveSingleError(
command, command,
DomainErrorCodes.Tenant.TenantEmptyId, DomainErrorCodes.Tenant.EmptyId,
"Tenant id may not be empty"); "Tenant id may not be empty");
} }

View File

@ -52,7 +52,7 @@ public sealed class CreateTenantCommandHandler : CommandHandlerBase,
new DomainNotification( new DomainNotification(
request.MessageType, request.MessageType,
$"There is already a tenant with Id {request.AggregateId}", $"There is already a tenant with Id {request.AggregateId}",
DomainErrorCodes.Tenant.TenantAlreadyExists)); DomainErrorCodes.Tenant.AlreadyExists));
return; return;
} }

View File

@ -16,7 +16,7 @@ public sealed class CreateTenantCommandValidation : AbstractValidator<CreateTena
{ {
RuleFor(cmd => cmd.AggregateId) RuleFor(cmd => cmd.AggregateId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) .WithErrorCode(DomainErrorCodes.Tenant.EmptyId)
.WithMessage("Tenant id may not be empty"); .WithMessage("Tenant id may not be empty");
} }
@ -24,10 +24,10 @@ public sealed class CreateTenantCommandValidation : AbstractValidator<CreateTena
{ {
RuleFor(cmd => cmd.Name) RuleFor(cmd => cmd.Name)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyName) .WithErrorCode(DomainErrorCodes.Tenant.EmptyName)
.WithMessage("Name may not be empty") .WithMessage("Name may not be empty")
.MaximumLength(MaxLengths.Tenant.Name) .MaximumLength(MaxLengths.Tenant.Name)
.WithErrorCode(DomainErrorCodes.Tenant.TenantNameExceedsMaxLength) .WithErrorCode(DomainErrorCodes.Tenant.NameExceedsMaxLength)
.WithMessage($"Name may not be longer than {MaxLengths.Tenant.Name} characters"); .WithMessage($"Name may not be longer than {MaxLengths.Tenant.Name} characters");
} }
} }

View File

@ -14,7 +14,7 @@ public sealed class DeleteTenantCommandValidation : AbstractValidator<DeleteTena
{ {
RuleFor(cmd => cmd.AggregateId) RuleFor(cmd => cmd.AggregateId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) .WithErrorCode(DomainErrorCodes.Tenant.EmptyId)
.WithMessage("Tenant id may not be empty"); .WithMessage("Tenant id may not be empty");
} }
} }

View File

@ -16,7 +16,7 @@ public sealed class UpdateTenantCommandValidation : AbstractValidator<UpdateTena
{ {
RuleFor(cmd => cmd.AggregateId) RuleFor(cmd => cmd.AggregateId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) .WithErrorCode(DomainErrorCodes.Tenant.EmptyId)
.WithMessage("Tenant id may not be empty"); .WithMessage("Tenant id may not be empty");
} }
@ -24,10 +24,10 @@ public sealed class UpdateTenantCommandValidation : AbstractValidator<UpdateTena
{ {
RuleFor(cmd => cmd.Name) RuleFor(cmd => cmd.Name)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyName) .WithErrorCode(DomainErrorCodes.Tenant.EmptyName)
.WithMessage("Name may not be empty") .WithMessage("Name may not be empty")
.MaximumLength(MaxLengths.Tenant.Name) .MaximumLength(MaxLengths.Tenant.Name)
.WithErrorCode(DomainErrorCodes.Tenant.TenantNameExceedsMaxLength) .WithErrorCode(DomainErrorCodes.Tenant.NameExceedsMaxLength)
.WithMessage($"Name may not be longer than {MaxLengths.Tenant.Name} characters"); .WithMessage($"Name may not be longer than {MaxLengths.Tenant.Name} characters");
} }
} }

View File

@ -53,7 +53,7 @@ public sealed class ChangePasswordCommandHandler : CommandHandlerBase,
new DomainNotification( new DomainNotification(
request.MessageType, request.MessageType,
"The password is incorrect", "The password is incorrect",
DomainErrorCodes.User.UserPasswordIncorrect)); DomainErrorCodes.User.PasswordIncorrect));
return; return;
} }

View File

@ -59,7 +59,7 @@ public sealed class CreateUserCommandHandler : CommandHandlerBase,
new DomainNotification( new DomainNotification(
request.MessageType, request.MessageType,
$"There is already a user with Id {request.UserId}", $"There is already a user with Id {request.UserId}",
DomainErrorCodes.User.UserAlreadyExists)); DomainErrorCodes.User.AlreadyExists));
return; return;
} }
@ -71,7 +71,7 @@ public sealed class CreateUserCommandHandler : CommandHandlerBase,
new DomainNotification( new DomainNotification(
request.MessageType, request.MessageType,
$"There is already a user with email {request.Email}", $"There is already a user with email {request.Email}",
DomainErrorCodes.User.UserAlreadyExists)); DomainErrorCodes.User.AlreadyExists));
return; return;
} }

View File

@ -21,7 +21,7 @@ public sealed class CreateUserCommandValidation : AbstractValidator<CreateUserCo
{ {
RuleFor(cmd => cmd.UserId) RuleFor(cmd => cmd.UserId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.User.UserEmptyId) .WithErrorCode(DomainErrorCodes.User.EmptyId)
.WithMessage("User id may not be empty"); .WithMessage("User id may not be empty");
} }
@ -29,7 +29,7 @@ public sealed class CreateUserCommandValidation : AbstractValidator<CreateUserCo
{ {
RuleFor(cmd => cmd.TenantId) RuleFor(cmd => cmd.TenantId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) .WithErrorCode(DomainErrorCodes.Tenant.EmptyId)
.WithMessage("Tenant id may not be empty"); .WithMessage("Tenant id may not be empty");
} }
@ -37,10 +37,10 @@ public sealed class CreateUserCommandValidation : AbstractValidator<CreateUserCo
{ {
RuleFor(cmd => cmd.Email) RuleFor(cmd => cmd.Email)
.EmailAddress() .EmailAddress()
.WithErrorCode(DomainErrorCodes.User.UserInvalidEmail) .WithErrorCode(DomainErrorCodes.User.InvalidEmail)
.WithMessage("Email is not a valid email address") .WithMessage("Email is not a valid email address")
.MaximumLength(MaxLengths.User.Email) .MaximumLength(MaxLengths.User.Email)
.WithErrorCode(DomainErrorCodes.User.UserEmailExceedsMaxLength) .WithErrorCode(DomainErrorCodes.User.EmailExceedsMaxLength)
.WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters"); .WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters");
} }
@ -48,10 +48,10 @@ public sealed class CreateUserCommandValidation : AbstractValidator<CreateUserCo
{ {
RuleFor(cmd => cmd.FirstName) RuleFor(cmd => cmd.FirstName)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.User.UserEmptyFirstName) .WithErrorCode(DomainErrorCodes.User.EmptyFirstName)
.WithMessage("FirstName may not be empty") .WithMessage("FirstName may not be empty")
.MaximumLength(MaxLengths.User.FirstName) .MaximumLength(MaxLengths.User.FirstName)
.WithErrorCode(DomainErrorCodes.User.UserFirstNameExceedsMaxLength) .WithErrorCode(DomainErrorCodes.User.FirstNameExceedsMaxLength)
.WithMessage($"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); .WithMessage($"FirstName may not be longer than {MaxLengths.User.FirstName} characters");
} }
@ -59,10 +59,10 @@ public sealed class CreateUserCommandValidation : AbstractValidator<CreateUserCo
{ {
RuleFor(cmd => cmd.LastName) RuleFor(cmd => cmd.LastName)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.User.UserEmptyLastName) .WithErrorCode(DomainErrorCodes.User.EmptyLastName)
.WithMessage("LastName may not be empty") .WithMessage("LastName may not be empty")
.MaximumLength(MaxLengths.User.LastName) .MaximumLength(MaxLengths.User.LastName)
.WithErrorCode(DomainErrorCodes.User.UserLastNameExceedsMaxLength) .WithErrorCode(DomainErrorCodes.User.LastNameExceedsMaxLength)
.WithMessage($"LastName may not be longer than {MaxLengths.User.LastName} characters"); .WithMessage($"LastName may not be longer than {MaxLengths.User.LastName} characters");
} }

View File

@ -14,7 +14,7 @@ public sealed class DeleteUserCommandValidation : AbstractValidator<DeleteUserCo
{ {
RuleFor(cmd => cmd.UserId) RuleFor(cmd => cmd.UserId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.User.UserEmptyId) .WithErrorCode(DomainErrorCodes.User.EmptyId)
.WithMessage("User id may not be empty"); .WithMessage("User id may not be empty");
} }
} }

View File

@ -64,7 +64,7 @@ public sealed class LoginUserCommandHandler : CommandHandlerBase,
new DomainNotification( new DomainNotification(
request.MessageType, request.MessageType,
"The password is incorrect", "The password is incorrect",
DomainErrorCodes.User.UserPasswordIncorrect)); DomainErrorCodes.User.PasswordIncorrect));
return ""; return "";
} }

View File

@ -17,10 +17,10 @@ public sealed class LoginUserCommandValidation : AbstractValidator<LoginUserComm
{ {
RuleFor(cmd => cmd.Email) RuleFor(cmd => cmd.Email)
.EmailAddress() .EmailAddress()
.WithErrorCode(DomainErrorCodes.User.UserInvalidEmail) .WithErrorCode(DomainErrorCodes.User.InvalidEmail)
.WithMessage("Email is not a valid email address") .WithMessage("Email is not a valid email address")
.MaximumLength(MaxLengths.User.Email) .MaximumLength(MaxLengths.User.Email)
.WithErrorCode(DomainErrorCodes.User.UserEmailExceedsMaxLength) .WithErrorCode(DomainErrorCodes.User.EmailExceedsMaxLength)
.WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters"); .WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters");
} }

View File

@ -70,7 +70,7 @@ public sealed class UpdateUserCommandHandler : CommandHandlerBase,
new DomainNotification( new DomainNotification(
request.MessageType, request.MessageType,
$"There is already a user with email {request.Email}", $"There is already a user with email {request.Email}",
DomainErrorCodes.User.UserAlreadyExists)); DomainErrorCodes.User.AlreadyExists));
return; return;
} }
} }

View File

@ -20,7 +20,7 @@ public sealed class UpdateUserCommandValidation : AbstractValidator<UpdateUserCo
{ {
RuleFor(cmd => cmd.UserId) RuleFor(cmd => cmd.UserId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.User.UserEmptyId) .WithErrorCode(DomainErrorCodes.User.EmptyId)
.WithMessage("User id may not be empty"); .WithMessage("User id may not be empty");
} }
@ -28,7 +28,7 @@ public sealed class UpdateUserCommandValidation : AbstractValidator<UpdateUserCo
{ {
RuleFor(cmd => cmd.TenantId) RuleFor(cmd => cmd.TenantId)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.Tenant.TenantEmptyId) .WithErrorCode(DomainErrorCodes.Tenant.EmptyId)
.WithMessage("Tenant id may not be empty"); .WithMessage("Tenant id may not be empty");
} }
@ -36,10 +36,10 @@ public sealed class UpdateUserCommandValidation : AbstractValidator<UpdateUserCo
{ {
RuleFor(cmd => cmd.Email) RuleFor(cmd => cmd.Email)
.EmailAddress() .EmailAddress()
.WithErrorCode(DomainErrorCodes.User.UserInvalidEmail) .WithErrorCode(DomainErrorCodes.User.InvalidEmail)
.WithMessage("Email is not a valid email address") .WithMessage("Email is not a valid email address")
.MaximumLength(MaxLengths.User.Email) .MaximumLength(MaxLengths.User.Email)
.WithErrorCode(DomainErrorCodes.User.UserEmailExceedsMaxLength) .WithErrorCode(DomainErrorCodes.User.EmailExceedsMaxLength)
.WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters"); .WithMessage($"Email may not be longer than {MaxLengths.User.Email} characters");
} }
@ -47,10 +47,10 @@ public sealed class UpdateUserCommandValidation : AbstractValidator<UpdateUserCo
{ {
RuleFor(cmd => cmd.FirstName) RuleFor(cmd => cmd.FirstName)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.User.UserEmptyFirstName) .WithErrorCode(DomainErrorCodes.User.EmptyFirstName)
.WithMessage("FirstName may not be empty") .WithMessage("FirstName may not be empty")
.MaximumLength(MaxLengths.User.FirstName) .MaximumLength(MaxLengths.User.FirstName)
.WithErrorCode(DomainErrorCodes.User.UserFirstNameExceedsMaxLength) .WithErrorCode(DomainErrorCodes.User.FirstNameExceedsMaxLength)
.WithMessage($"FirstName may not be longer than {MaxLengths.User.FirstName} characters"); .WithMessage($"FirstName may not be longer than {MaxLengths.User.FirstName} characters");
} }
@ -58,10 +58,10 @@ public sealed class UpdateUserCommandValidation : AbstractValidator<UpdateUserCo
{ {
RuleFor(cmd => cmd.LastName) RuleFor(cmd => cmd.LastName)
.NotEmpty() .NotEmpty()
.WithErrorCode(DomainErrorCodes.User.UserEmptyLastName) .WithErrorCode(DomainErrorCodes.User.EmptyLastName)
.WithMessage("LastName may not be empty") .WithMessage("LastName may not be empty")
.MaximumLength(MaxLengths.User.LastName) .MaximumLength(MaxLengths.User.LastName)
.WithErrorCode(DomainErrorCodes.User.UserLastNameExceedsMaxLength) .WithErrorCode(DomainErrorCodes.User.LastNameExceedsMaxLength)
.WithMessage($"LastName may not be longer than {MaxLengths.User.LastName} characters"); .WithMessage($"LastName may not be longer than {MaxLengths.User.LastName} characters");
} }
@ -69,7 +69,7 @@ public sealed class UpdateUserCommandValidation : AbstractValidator<UpdateUserCo
{ {
RuleFor(cmd => cmd.Role) RuleFor(cmd => cmd.Role)
.IsInEnum() .IsInEnum()
.WithErrorCode(DomainErrorCodes.User.UserInvalidRole) .WithErrorCode(DomainErrorCodes.User.InvalidRole)
.WithMessage("Role is not a valid role"); .WithMessage("Role is not a valid role");
} }
} }

View File

@ -5,37 +5,37 @@ public static class DomainErrorCodes
public static class User public static class User
{ {
// User Validation // User Validation
public const string UserEmptyId = "USER_EMPTY_ID"; public const string EmptyId = "USER_EMPTY_ID";
public const string UserEmptyFirstName = "USER_EMPTY_FIRST_NAME"; public const string EmptyFirstName = "USER_EMPTY_FIRST_NAME";
public const string UserEmptyLastName = "USER_EMPTY_LAST_NAME"; public const string EmptyLastName = "USER_EMPTY_LAST_NAME";
public const string UserEmailExceedsMaxLength = "USER_EMAIL_EXCEEDS_MAX_LENGTH"; public const string EmailExceedsMaxLength = "USER_EMAIL_EXCEEDS_MAX_LENGTH";
public const string UserFirstNameExceedsMaxLength = "USER_FIRST_NAME_EXCEEDS_MAX_LENGTH"; public const string FirstNameExceedsMaxLength = "USER_FIRST_NAME_EXCEEDS_MAX_LENGTH";
public const string UserLastNameExceedsMaxLength = "USER_LAST_NAME_EXCEEDS_MAX_LENGTH"; public const string LastNameExceedsMaxLength = "USER_LAST_NAME_EXCEEDS_MAX_LENGTH";
public const string UserInvalidEmail = "USER_INVALID_EMAIL"; public const string InvalidEmail = "USER_INVALID_EMAIL";
public const string UserInvalidRole = "USER_INVALID_ROLE"; public const string InvalidRole = "USER_INVALID_ROLE";
// User Password Validation // User Password Validation
public const string UserEmptyPassword = "USER_PASSWORD_MAY_NOT_BE_EMPTY"; public const string EmptyPassword = "USER_PASSWORD_MAY_NOT_BE_EMPTY";
public const string UserShortPassword = "USER_PASSWORD_MAY_NOT_BE_SHORTER_THAN_6_CHARACTERS"; public const string ShortPassword = "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 LongPassword = "USER_PASSWORD_MAY_NOT_BE_LONGER_THAN_50_CHARACTERS";
public const string UserUppercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_UPPERCASE_LETTER"; public const string UppercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_UPPERCASE_LETTER";
public const string UserLowercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_LOWERCASE_LETTER"; public const string LowercaseLetterPassword = "USER_PASSWORD_MUST_CONTAIN_A_LOWERCASE_LETTER";
public const string UserNumberPassword = "USER_PASSWORD_MUST_CONTAIN_A_NUMBER"; public const string NumberPassword = "USER_PASSWORD_MUST_CONTAIN_A_NUMBER";
public const string UserSpecialCharPassword = "USER_PASSWORD_MUST_CONTAIN_A_SPECIAL_CHARACTER"; public const string SpecialCharPassword = "USER_PASSWORD_MUST_CONTAIN_A_SPECIAL_CHARACTER";
// General // General
public const string UserAlreadyExists = "USER_ALREADY_EXISTS"; public const string AlreadyExists = "USER_ALREADY_EXISTS";
public const string UserPasswordIncorrect = "USER_PASSWORD_INCORRECT"; public const string PasswordIncorrect = "USER_PASSWORD_INCORRECT";
} }
public static class Tenant public static class Tenant
{ {
// Tenant Validation // Tenant Validation
public const string TenantEmptyId = "TENANT_EMPTY_ID"; public const string EmptyId = "TENANT_EMPTY_ID";
public const string TenantEmptyName = "TENANT_EMPTY_NAME"; public const string EmptyName = "TENANT_EMPTY_NAME";
public const string TenantNameExceedsMaxLength = "TENANT_NAME_EXCEEDS_MAX_LENGTH"; public const string NameExceedsMaxLength = "TENANT_NAME_EXCEEDS_MAX_LENGTH";
// General // General
public const string TenantAlreadyExists = "TENANT_ALREADY_EXISTS"; public const string AlreadyExists = "TENANT_ALREADY_EXISTS";
} }
} }

View File

@ -23,13 +23,13 @@ public static partial class CustomValidator
int maxLength = 50) int maxLength = 50)
{ {
var options = ruleBuilder var options = ruleBuilder
.NotEmpty().WithErrorCode(DomainErrorCodes.User.UserEmptyPassword) .NotEmpty().WithErrorCode(DomainErrorCodes.User.EmptyPassword)
.MinimumLength(minLength).WithErrorCode(DomainErrorCodes.User.UserShortPassword) .MinimumLength(minLength).WithErrorCode(DomainErrorCodes.User.ShortPassword)
.MaximumLength(maxLength).WithErrorCode(DomainErrorCodes.User.UserLongPassword) .MaximumLength(maxLength).WithErrorCode(DomainErrorCodes.User.LongPassword)
.Matches("[A-Z]").WithErrorCode(DomainErrorCodes.User.UserUppercaseLetterPassword) .Matches("[A-Z]").WithErrorCode(DomainErrorCodes.User.UppercaseLetterPassword)
.Matches("[a-z]").WithErrorCode(DomainErrorCodes.User.UserLowercaseLetterPassword) .Matches("[a-z]").WithErrorCode(DomainErrorCodes.User.LowercaseLetterPassword)
.Matches("[0-9]").WithErrorCode(DomainErrorCodes.User.UserNumberPassword) .Matches("[0-9]").WithErrorCode(DomainErrorCodes.User.NumberPassword)
.Matches("[^a-zA-Z0-9]").WithErrorCode(DomainErrorCodes.User.UserSpecialCharPassword); .Matches("[^a-zA-Z0-9]").WithErrorCode(DomainErrorCodes.User.SpecialCharPassword);
return options; return options;
} }