using FluentValidation;

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

/// <summary>
/// Validator for UpdateStoryCommand
/// </summary>
public sealed class UpdateStoryCommandValidator : AbstractValidator<UpdateStoryCommand>
{
    public UpdateStoryCommandValidator()
    {
        RuleFor(x => x.StoryId)
            .NotEmpty().WithMessage("Story ID is required");

        RuleFor(x => x.Title)
            .NotEmpty().WithMessage("Story title is required")
            .MaximumLength(200).WithMessage("Story title cannot exceed 200 characters");

        RuleFor(x => x.Status)
            .Must(s => s == null || s == "To Do" || s == "In Progress" || s == "In Review" || s == "Done" || s == "Blocked")
            .WithMessage("Status must be one of: To Do, In Progress, In Review, Done, Blocked");

        RuleFor(x => x.Priority)
            .Must(p => p == null || p == "Low" || p == "Medium" || p == "High" || p == "Urgent")
            .WithMessage("Priority must be one of: Low, Medium, High, Urgent");

        RuleFor(x => x.EstimatedHours)
            .GreaterThanOrEqualTo(0).When(x => x.EstimatedHours.HasValue)
            .WithMessage("Estimated hours cannot be negative");
    }
}
