using CalledIt.Domain.Dtos;
using FluentValidation;

namespace CalledIt.Domain.Validators;

public class UpdateMatchDtoValidator : AbstractValidator<UpdateMatchDto>
{
    public UpdateMatchDtoValidator()
    {
        RuleFor(x => x.CompetitionId).GreaterThan(0);
        RuleFor(x => x.HomeTeamId).GreaterThan(0);
        RuleFor(x => x.AwayTeamId).GreaterThan(0);
        RuleFor(x => x.AwayTeamId)
            .NotEqual(x => x.HomeTeamId)
            .WithMessage("Home team and away team must be different.");
        RuleFor(x => x.Round).NotEmpty();
        RuleFor(x => x.HomeScore).GreaterThanOrEqualTo(0).When(x => x.HomeScore.HasValue);
        RuleFor(x => x.AwayScore).GreaterThanOrEqualTo(0).When(x => x.AwayScore.HasValue);
    }
}
