created validators for groups, achievements, designations, auth
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using BeReadyBackend.DTO.Achievements;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Achievements;
|
||||
|
||||
public class GetAchievementDtoValidator : Validator<GetAchievementDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using BeReadyBackend.DTO.Achievements;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Achievements;
|
||||
|
||||
public class UnlockAchievementDtoValidator : Validator<UnlockAchievementDto>
|
||||
{
|
||||
public UnlockAchievementDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.AchievementId)
|
||||
.NotEmpty()
|
||||
.WithMessage("AchievementId cannot be empty")
|
||||
.GreaterThan(0)
|
||||
.WithMessage("AchievementId must be greater than 0");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using BeReadyBackend.DTO.Auth;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Auth;
|
||||
|
||||
public class GetTokenDtoValidator : Validator<GetTokenDto>
|
||||
{
|
||||
public GetTokenDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Token)
|
||||
.NotEmpty()
|
||||
.WithMessage("Token cannot be empty");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using BeReadyBackend.DTO.Auth;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Auth;
|
||||
|
||||
public class LoginDtoValidator: Validator<LoginDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using BeReadyBackend.DTO.Auth;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Auth;
|
||||
|
||||
public class RefreshTokenDtoValidator : Validator<RefreshTokenDto>
|
||||
{
|
||||
public RefreshTokenDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Token)
|
||||
.NotEmpty()
|
||||
.WithMessage("Token cannot be empty");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using BeReadyBackend.DTO.Designations;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Designations;
|
||||
|
||||
public class GetDesignationDtoValidator : Validator<GetDesignationDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Groups;
|
||||
|
||||
public class CreateGroupDtoValidator : Validator<CreateGroupDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Groups;
|
||||
|
||||
public class CreateUserGroupDtoValidator : Validator<CreateUserGroupDto>
|
||||
{
|
||||
public CreateUserGroupDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.UserId)
|
||||
.NotEmpty()
|
||||
.WithMessage("UserId cannot be empty")
|
||||
.GreaterThan(0)
|
||||
.WithMessage("UserId must exceed 1 hour");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Groups;
|
||||
|
||||
public class GetGroupDetailsDtoValidator : Validator<GetGroupDetailsDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Groups;
|
||||
|
||||
public class GetGroupDtoValidator : Validator<GetGroupDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Groups;
|
||||
|
||||
public class GetGroupRankingDtoValidator : Validator<GetGroupRankingDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Groups;
|
||||
|
||||
public class GetProofDtoValidator : Validator<GetProofDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BeReadyBackend.Validators.Groups;
|
||||
|
||||
public class GetUserGroupDtoValidator : Validator<GetUserGroupDto>
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user