using FluentValidation;

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

/// <summary>
/// Validator for CreateStoryCommand
/// </summary>
public sealed class CreateStoryCommandValidator : AbstractValidator<CreateStoryCommand>
{
    public CreateStoryCommandValidator()
    {
        RuleFor(x => x.EpicId)
            .NotEmpty().WithMessage("Epic 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.Priority)
            .NotEmpty().WithMessage("Priority is required")
            .Must(p => 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");

        RuleFor(x => x.CreatedBy)
            .NotEmpty().WithMessage("Created by user ID is required");
    }
}
