diff --git a/BeReadyBackend/Validators/Achievements/GetAchievementDtoValidator.cs b/BeReadyBackend/Validators/Achievements/GetAchievementDtoValidator.cs new file mode 100644 index 0000000..da6df0d --- /dev/null +++ b/BeReadyBackend/Validators/Achievements/GetAchievementDtoValidator.cs @@ -0,0 +1,31 @@ +using BeReadyBackend.DTO.Achievements; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Achievements; + +public class GetAchievementDtoValidator : Validator +{ + public GetAchievementDtoValidator() + { + RuleFor(x => x.Id) + .GreaterThan(0) + .WithMessage("Id must be greater than 0"); + + RuleFor(x => x.Description) + .NotEmpty() + .WithMessage("Description must be specified") + .MinimumLength(2) + .WithMessage("Description must contain more than 2 characters") + .MaximumLength(200) // Add BDD + .WithMessage("Description cannot contain more than 200 characters"); + + RuleFor(x => x.Label) + .NotEmpty() + .WithMessage("Label must be specified") + .MinimumLength(2) + .WithMessage("Description must contain more than 2 characters") + .MaximumLength(200) // Add BDD + .WithMessage("Description cannot contain more than 200 characters"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Achievements/UnlockAchievementDtoValidator.cs b/BeReadyBackend/Validators/Achievements/UnlockAchievementDtoValidator.cs new file mode 100644 index 0000000..453d0fb --- /dev/null +++ b/BeReadyBackend/Validators/Achievements/UnlockAchievementDtoValidator.cs @@ -0,0 +1,18 @@ +using BeReadyBackend.DTO.Achievements; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Achievements; + +public class UnlockAchievementDtoValidator : Validator +{ + public UnlockAchievementDtoValidator() + { + RuleFor(x => x.AchievementId) + .NotEmpty() + .WithMessage("AchievementId cannot be empty") + .GreaterThan(0) + .WithMessage("AchievementId must be greater than 0"); + + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Auth/GetTokenDtoValidator.cs b/BeReadyBackend/Validators/Auth/GetTokenDtoValidator.cs new file mode 100644 index 0000000..b10e2e1 --- /dev/null +++ b/BeReadyBackend/Validators/Auth/GetTokenDtoValidator.cs @@ -0,0 +1,15 @@ +using BeReadyBackend.DTO.Auth; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Auth; + +public class GetTokenDtoValidator : Validator +{ + public GetTokenDtoValidator() + { + RuleFor(x => x.Token) + .NotEmpty() + .WithMessage("Token cannot be empty"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Auth/LoginDtoValidator.cs b/BeReadyBackend/Validators/Auth/LoginDtoValidator.cs new file mode 100644 index 0000000..da5284a --- /dev/null +++ b/BeReadyBackend/Validators/Auth/LoginDtoValidator.cs @@ -0,0 +1,23 @@ +using BeReadyBackend.DTO.Auth; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Auth; + +public class LoginDtoValidator: Validator +{ + public LoginDtoValidator() + { + RuleFor(x => x.Username) + .NotEmpty() + .WithMessage("Username is required") + .MaximumLength(50) + .WithMessage("Username cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Username must exceed 2 characters"); + + RuleFor(x => x.Password) + .NotEmpty() + .WithMessage("Password is required"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Auth/RefreshTokenDtoValidator.cs b/BeReadyBackend/Validators/Auth/RefreshTokenDtoValidator.cs new file mode 100644 index 0000000..22f6eba --- /dev/null +++ b/BeReadyBackend/Validators/Auth/RefreshTokenDtoValidator.cs @@ -0,0 +1,15 @@ +using BeReadyBackend.DTO.Auth; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Auth; + +public class RefreshTokenDtoValidator : Validator +{ + public RefreshTokenDtoValidator() + { + RuleFor(x => x.Token) + .NotEmpty() + .WithMessage("Token cannot be empty"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Designations/GetDesignationDtoValidator.cs b/BeReadyBackend/Validators/Designations/GetDesignationDtoValidator.cs new file mode 100644 index 0000000..7b48147 --- /dev/null +++ b/BeReadyBackend/Validators/Designations/GetDesignationDtoValidator.cs @@ -0,0 +1,25 @@ +using BeReadyBackend.DTO.Designations; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Designations; + +public class GetDesignationDtoValidator : Validator +{ + public GetDesignationDtoValidator() + { + RuleFor(x => x.Id) + .NotEmpty() + .WithMessage("Id cannot be empty") + .GreaterThan(0) + .WithMessage("Id must be greater than 0"); + + RuleFor(x => x.Label) + .NotEmpty() + .WithMessage("Label cannot be empty") + .MaximumLength(100) // Add BDD + .WithMessage("Label cannot contain more than 100 characters") + .MinimumLength(2) + .WithMessage("Label must contain more than 2 characters"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs b/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs new file mode 100644 index 0000000..ece2ebd --- /dev/null +++ b/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs @@ -0,0 +1,41 @@ +using BeReadyBackend.DTO.Groups; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Groups; + +public class CreateGroupDtoValidator : Validator +{ + public CreateGroupDtoValidator() + { + RuleFor(x => x.Label) + .NotEmpty() + .WithMessage("Label cannot be empty") + .MaximumLength(50) // Add BDD + .WithMessage("Label cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Label must exceed 2 characters"); + + RuleFor(x => x.Title) + .NotEmpty() + .WithMessage("Title cannot be empty") + .MaximumLength(50) // Add BDD + .WithMessage("Title cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Title must exceed 2 characters"); + + RuleFor(x => x.Description) + .NotEmpty() + .WithMessage("Description cannot be empty") + .MaximumLength(200) // Add BDD + .WithMessage("Description cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Description must exceed 2 characters"); + + RuleFor(x => x.Duration) + .NotEmpty() + .WithMessage("Duration cannot be empty") + .GreaterThan(0) + .WithMessage("Duration must exceed 1 hour"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Groups/CreateUserGroupDtoValidator.cs b/BeReadyBackend/Validators/Groups/CreateUserGroupDtoValidator.cs new file mode 100644 index 0000000..72555d6 --- /dev/null +++ b/BeReadyBackend/Validators/Groups/CreateUserGroupDtoValidator.cs @@ -0,0 +1,17 @@ +using BeReadyBackend.DTO.Groups; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Groups; + +public class CreateUserGroupDtoValidator : Validator +{ + public CreateUserGroupDtoValidator() + { + RuleFor(x => x.UserId) + .NotEmpty() + .WithMessage("UserId cannot be empty") + .GreaterThan(0) + .WithMessage("UserId must exceed 1 hour"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Groups/GetGroupDetailsDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetGroupDetailsDtoValidator.cs new file mode 100644 index 0000000..1486436 --- /dev/null +++ b/BeReadyBackend/Validators/Groups/GetGroupDetailsDtoValidator.cs @@ -0,0 +1,55 @@ +using BeReadyBackend.DTO.Groups; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Groups; + +public class GetGroupDetailsDtoValidator : Validator +{ + public GetGroupDetailsDtoValidator() + { + RuleFor(x => x.Id) + .NotEmpty() + .WithMessage("Id cannot be empty") + .GreaterThan(0) + .WithMessage("Id must be greater than zero"); + + RuleFor(x => x.Label) + .NotEmpty() + .WithMessage("Label cannot be empty") + .MaximumLength(50) // Add BDD + .WithMessage("Label cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Label must exceed 2 characters"); + + RuleFor(x => x.IsFinished) + .NotEmpty() + .WithMessage("IsFinished cannot be empty"); + + RuleFor(x => x.Title) + .NotEmpty() + .WithMessage("Title cannot be empty") + .MaximumLength(100) // Add BDD + .WithMessage("Title cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Title must exceed 2 characters"); + + RuleFor(x => x.Description) + .NotEmpty() + .WithMessage("Description cannot be empty") + .MaximumLength(200) // Add BDD + .WithMessage("Description cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Description must exceed 2 characters"); + + RuleFor(x => x.Duration) + .NotEmpty() + .WithMessage("Duration cannot be empty") + .GreaterThan(0) + .WithMessage("Duration must exceed 1 hour"); + + RuleFor(x => x.CreationDate) + .NotEmpty() + .WithMessage("CreationDate cannot be empty"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Groups/GetGroupDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetGroupDtoValidator.cs new file mode 100644 index 0000000..8b3c761 --- /dev/null +++ b/BeReadyBackend/Validators/Groups/GetGroupDtoValidator.cs @@ -0,0 +1,29 @@ +using BeReadyBackend.DTO.Groups; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Groups; + +public class GetGroupDtoValidator : Validator +{ + public GetGroupDtoValidator() + { + RuleFor(x => x.Id) + .NotEmpty() + .WithMessage("Id cannot be empty") + .GreaterThan(0) + .WithMessage("Id must be greater than zero"); + + RuleFor(x => x.Label) + .NotEmpty() + .WithMessage("Label cannot be empty") + .MaximumLength(50) // Add BDD + .WithMessage("Label cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Label must exceed 2 characters"); + + RuleFor(x => x.IsFinished) + .NotEmpty() + .WithMessage("IsFinished cannot be empty"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Groups/GetGroupRankingDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetGroupRankingDtoValidator.cs new file mode 100644 index 0000000..ed0ae21 --- /dev/null +++ b/BeReadyBackend/Validators/Groups/GetGroupRankingDtoValidator.cs @@ -0,0 +1,29 @@ +using BeReadyBackend.DTO.Groups; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Groups; + +public class GetGroupRankingDtoValidator : Validator +{ + public GetGroupRankingDtoValidator() + { + RuleFor(x => x.UserId) + .NotEmpty() + .WithMessage("Id cannot be empty") + .GreaterThan(0) + .WithMessage("Id must be greater than 0"); + + RuleFor(x => x.Username) + .NotEmpty() + .WithMessage("Username cannot be empty") + .MaximumLength(50) + .WithMessage("Username cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Username must exceed 2 characters"); + + RuleFor(x => x.Score) + .NotEmpty() + .WithMessage("Score cannot be empty"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Groups/GetProofDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetProofDtoValidator.cs new file mode 100644 index 0000000..cb24ca8 --- /dev/null +++ b/BeReadyBackend/Validators/Groups/GetProofDtoValidator.cs @@ -0,0 +1,33 @@ +using BeReadyBackend.DTO.Groups; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Groups; + +public class GetProofDtoValidator : Validator +{ + public GetProofDtoValidator() + { + RuleFor(x => x.UserId) + .NotEmpty() + .WithMessage("Id cannot be empty") + .GreaterThan(0) + .WithMessage("Id must be greater than 0"); + + RuleFor(x => x.Username) + .NotEmpty() + .WithMessage("Username cannot be empty") + .MaximumLength(50) + .WithMessage("Username cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Username must exceed 2 characters"); + + RuleFor(x => x.Proof) + .NotEmpty() + .WithMessage("Proof cannot be empty"); + + RuleFor(x => x.Score) + .NotEmpty() + .WithMessage("Score cannot be empty"); + } +} \ No newline at end of file diff --git a/BeReadyBackend/Validators/Groups/GetUserGroupDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetUserGroupDtoValidator.cs new file mode 100644 index 0000000..b290ebe --- /dev/null +++ b/BeReadyBackend/Validators/Groups/GetUserGroupDtoValidator.cs @@ -0,0 +1,33 @@ +using BeReadyBackend.DTO.Groups; +using FastEndpoints; +using FluentValidation; + +namespace BeReadyBackend.Validators.Groups; + +public class GetUserGroupDtoValidator : Validator +{ + public GetUserGroupDtoValidator() + { + RuleFor(x => x.Id) + .NotEmpty() + .WithMessage("Id cannot be empty") + .GreaterThan(0) + .WithMessage("Id must be greater than 0"); + + RuleFor(x => x.Username) + .NotEmpty() + .WithMessage("Username cannot be empty") + .MaximumLength(50) + .WithMessage("Username cannot exceed 50 characters") + .MinimumLength(2) + .WithMessage("Username must exceed 2 characters"); + + RuleFor(x => x.Grade) + .NotEmpty() + .WithMessage("Grade cannot be empty"); + + RuleFor(x => x.Score) + .NotEmpty() + .WithMessage("Score cannot be empty"); + } +} \ No newline at end of file