using FluentValidation;
using Indotalent.Shared.Consts;

namespace Indotalent.Features.Inventory.Product.Cqrs;

public class UpdateProductValidator : AbstractValidator<UpdateProductRequest>
{
    public UpdateProductValidator()
    {
        RuleFor(x => x.Id)
            .NotEmpty().WithMessage("ID is required for update");

        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Product Name is required")
            .MaximumLength(GlobalConsts.StringLengthShort);

        RuleFor(x => x.UnitMeasureId)
            .NotEmpty().WithMessage("Unit of Measure is required");

        RuleFor(x => x.ProductGroupId)
            .NotEmpty().WithMessage("Product Group is required");

        RuleFor(x => x.UnitPrice)
            .GreaterThanOrEqualTo(0).WithMessage("Unit Price cannot be negative");
    }
}