using FluentValidation; using ProposalSystem.Application.DTOs; namespace ProposalSystem.Application.Validators; public class BulkUpdateLineItemsValidator : AbstractValidator { public BulkUpdateLineItemsValidator() { RuleFor(x => x.LineItems).NotNull(); RuleForEach(x => x.LineItems).ChildRules(entry => { entry.RuleFor(x => x.Description) .NotEmpty().WithMessage("Description is required") .MaximumLength(1000); entry.RuleFor(x => x.Quantity) .GreaterThan(0).WithMessage("Quantity must be positive"); entry.RuleFor(x => x.Unit) .NotEmpty().WithMessage("Unit is required") .MaximumLength(50); entry.RuleFor(x => x.TotalPrice) .GreaterThanOrEqualTo(0).WithMessage("Total price cannot be negative"); entry.RuleFor(x => x.UnitPrice) .GreaterThanOrEqualTo(0) .When(x => x.UnitPrice.HasValue) .WithMessage("Unit price cannot be negative"); entry.RuleFor(x => x.PricingMode).IsInEnum(); entry.RuleFor(x => x.Source).IsInEnum(); entry.RuleFor(x => x.SortOrder).GreaterThanOrEqualTo(0); }); } }