* Extended functionalities
* Added different UIs
This commit is contained in:
19
MealPlan.Api/Validators/IngredientCatalogValidators.cs
Normal file
19
MealPlan.Api/Validators/IngredientCatalogValidators.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user