using FluentValidation;

namespace ColaFlow.Modules.ProjectManagement.Application.Commands.UpdateTaskStatus;

/// <summary>
/// Validator for UpdateTaskStatusCommand
/// </summary>
public sealed class UpdateTaskStatusCommandValidator : AbstractValidator<UpdateTaskStatusCommand>
{
    public UpdateTaskStatusCommandValidator()
    {
        RuleFor(x => x.TaskId)
            .NotEmpty()
            .WithMessage("TaskId is required");

        RuleFor(x => x.NewStatus)
            .NotEmpty()
            .WithMessage("NewStatus is required")
            .Must(BeValidStatus)
            .WithMessage("NewStatus must be one of: ToDo, InProgress, Done, Blocked");
    }

    private bool BeValidStatus(string status)
    {
        var validStatuses = new[] { "ToDo", "InProgress", "Done", "Blocked" };
        return validStatuses.Contains(status, StringComparer.OrdinalIgnoreCase);
    }
}
