using Baya.Domain.Entities.Booking;
using FluentValidation;

namespace Baya.Application.Features.Booking.Commands.CreateBookingRequest;

public sealed class CreateBookingRequestCommandValidator : AbstractValidator<CreateBookingRequestCommand>
{
    public CreateBookingRequestCommandValidator()
    {
        RuleFor(x => x.NurseId).GreaterThan(0);
        RuleFor(x => x.VariantId).GreaterThan(0);
        RuleFor(x => x.PatientId).GreaterThan(0);
        RuleFor(x => x.CustomerAddressId).GreaterThan(0);

        RuleFor(x => x.RequestedTimeEnd)
            .GreaterThan(x => x.RequestedTimeStart)
            .WithMessage("requested_time_end must be after requested_time_start.");

        // Gender is load-bearing — it must be supplied and in the closed set; never silently defaulted.
        RuleFor(x => x.RequiredCaregiverGender)
            .NotEmpty()
            .Must(CaregiverGender.IsValid)
            .WithMessage("required_caregiver_gender must be one of: male, female, any.");

        RuleFor(x => x.CustomerNotes).MaximumLength(1000);

        // requested_date "not in the past" needs the injected clock, so it is enforced in the handler.
    }
}
