* Extended functionalities

* Added different UIs
This commit is contained in:
2026-06-24 21:43:40 +02:00
parent 282f4864c4
commit f15bb7a916
348 changed files with 59057 additions and 498 deletions

View File

@@ -0,0 +1,36 @@
using FluentValidation;
using MealPlan.Api.DTOs.Recipe;
namespace MealPlan.Api.Validators;
public class CreateRecipeValidator : AbstractValidator<CreateRecipeDto>
{
public CreateRecipeValidator()
{
RuleFor(x => x.Name).NotEmpty().MaximumLength(255);
RuleFor(x => x.MealCategory).InclusiveBetween(0, 3);
RuleFor(x => x.Calories).GreaterThanOrEqualTo(0).When(x => x.Calories.HasValue);
RuleFor(x => x.PrepTimeMinutes).GreaterThanOrEqualTo(0).When(x => x.PrepTimeMinutes.HasValue);
RuleForEach(x => x.Ingredients).SetValidator(new CreateIngredientValidator());
RuleForEach(x => x.Steps).SetValidator(new CreateRecipeStepValidator());
}
}
public class CreateIngredientValidator : AbstractValidator<CreateIngredientDto>
{
public CreateIngredientValidator()
{
RuleFor(x => x.Name).NotEmpty().MaximumLength(255);
RuleFor(x => x.Unit).MaximumLength(50).When(x => x.Unit != null);
RuleFor(x => x.AmountGrams).GreaterThanOrEqualTo(0).When(x => x.AmountGrams.HasValue);
}
}
public class CreateRecipeStepValidator : AbstractValidator<CreateRecipeStepDto>
{
public CreateRecipeStepValidator()
{
RuleFor(x => x.StepNumber).GreaterThan(0);
RuleFor(x => x.Description).NotEmpty();
}
}