using FluentValidation;
using IWS5.Core.Models.Request;
using IWS5.DatabaseAccess.Interfaces;

namespace IWS5.Services.Validators;
public class UpdateFieldListOfValuesRequestValidator: AbstractValidator<UpdateFieldListOfValuesRequest>
{
    public UpdateFieldListOfValuesRequestValidator(IFieldDefinitionRepository fieldDefinitionRepository)
    {
        RuleFor(x => x.WorkItemId).GreaterThan(0).WithMessage("Work item ID is required.");

        RuleFor(x => x.UpdatedFields)
            .NotEmpty().WithMessage("At least one field is required.")
            .ForEach(field => field.SetValidator(new UpdateFieldValueRequestValidator(fieldDefinitionRepository)));
    }
}
