InvitesRepositoryTests

+ other reworks
This commit is contained in:
Artemy
2025-06-24 19:17:27 +07:00
parent 80e2ec30c6
commit f99ec0b17b
12 changed files with 378 additions and 23 deletions
@@ -4,6 +4,7 @@ namespace Govor.Core.Infrastructure.Validators;
public class InvitationValidator : IObjectValidator<Invitation>
{
public const int MIN_INVITATION_LENGTH = 10;
public void Validate(Invitation inv)
{
try
@@ -18,6 +19,8 @@ public class InvitationValidator : IObjectValidator<Invitation>
throw new ArgumentException("EndDate cannot be less than StartDate", nameof(inv.EndDate));
if(inv.MaxParticipants <= 0)
throw new ArgumentException("MaxParticipants cannot be less than 0", nameof(inv.MaxParticipants));
if(inv.Code == string.Empty || inv.Code.Length < MIN_INVITATION_LENGTH)
throw new ArgumentException($"Code cannot be empty or less then {MIN_INVITATION_LENGTH}", nameof(inv.Code));
}
catch (Exception ex)
{