using FluentValidation;
using MealPlan.Api.DTOs.IngredientCatalog;

namespace MealPlan.Api.Validators;

public class UpsertIngredientNutritionItemValidator : AbstractValidator<UpsertIngredientNutritionItemDto>
{
    public UpsertIngredientNutritionItemValidator()
    {
        RuleFor(x => x.CategoryId).GreaterThan(0);
        RuleFor(x => x.Name).NotEmpty().MaximumLength(255);
        RuleFor(x => x.NamePl).MaximumLength(255).When(x => x.NamePl != null);
        RuleFor(x => x.CaloriesPer100G).GreaterThanOrEqualTo(0);
        RuleFor(x => x.ProteinGPer100G).GreaterThanOrEqualTo(0);
        RuleFor(x => x.FatGPer100G).GreaterThanOrEqualTo(0);
        RuleFor(x => x.CarbsGPer100G).GreaterThanOrEqualTo(0);
        RuleFor(x => x.FiberGPer100G).GreaterThanOrEqualTo(0).When(x => x.FiberGPer100G.HasValue);
    }
}
