using FluentValidation;

namespace Baya.Application.Features.Verification.Commands.ReviewStep;

// StepId is route-supplied. Credential-field requirements that depend on the step's code (e.g. criminal
// record requires expires_at) are enforced in the handler, where the step is known.
public sealed class AdminReviewStepCommandValidator : AbstractValidator<AdminReviewStepCommand>
{
    public AdminReviewStepCommandValidator()
    {
        RuleFor(x => x.RejectionReason)
            .NotEmpty()
            .MaximumLength(1000)
            .When(x => !x.Approve)
            .WithMessage("A rejection reason is required when rejecting a step.");

        RuleFor(x => x.CredentialNumber).MaximumLength(100);
        RuleFor(x => x.HolderName).MaximumLength(200);
        RuleFor(x => x.IssuingAuthority).MaximumLength(200);
        RuleFor(x => x.VerificationSource).MaximumLength(300);
    }
}
