public CreateRecipeCommandValidator() { RuleFor(x => x.Id) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(CreateRecipeCommand.Id))); RuleFor(x => x.Name) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(CreateRecipeCommand.Name))); RuleFor(x => x.Description) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(CreateRecipeCommand.Description))); RuleFor(x => x.RecipeInfo) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(CreateRecipeCommand.RecipeInfo))); RuleFor(x => x.RecipeIngredients) .NotEmpty() .WithMessage(ValidationMessages.NotEmpty(nameof(CreateRecipeCommand.RecipeIngredients))); RuleFor(x => x.RecipeInfo) .SetValidator(new RecipeDetailsValidator()); RuleForEach(x => x.RecipeIngredients) .SetValidator(new RecipeIngredientValidator()); }
public RecipeIngredientValidator() { RuleFor(x => x.Grams) .GreaterThanOrEqualTo(1) .WithMessage(ValidationMessages.GreaterThanOrEqualTo(nameof(RecipeIngredient.Grams), 0)); RuleFor(x => x.IngredientId) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(RecipeIngredient.IngredientId))); }
public CreateIngredientCommandValidator() { RuleFor(x => x.Id) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(CreateIngredientCommand.Id))); RuleFor(x => x.Name) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(CreateIngredientCommand.Name))); RuleFor(x => x.Shares) .NotEmpty() .WithMessage(ValidationMessages.NotEmpty(nameof(CreateIngredientCommand.Shares))); RuleForEach(x => x.Shares) .SetValidator(new MacroNutrientsSharesValidator()); }
public GetIngredientQueryValidator() { RuleFor(x => x.IngredientId) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(GetIngredientQuery.IngredientId))); }
public DeleteRecipeCommandValidator() { RuleFor(x => x.Id) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(DeleteRecipeCommand.Id))); }
public GetRecipeQueryValidator() { RuleFor(x => x.Id) .NotNull() .WithMessage(ValidationMessages.NotNull(nameof(GetByIdQuery.Id))); }