Esempio n. 1
0
        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 RecipeDetailsValidator()
        {
            RuleFor(x => x.PreparationTime)
            .GreaterThanOrEqualTo(0)
            .WithMessage(ValidationMessages.GreaterThanOrEqualTo(nameof(RecipeInfo.PreparationTime), 0));

            RuleFor(x => x.ApproximateCost)
            .GreaterThanOrEqualTo(0)
            .WithMessage(ValidationMessages.GreaterThanOrEqualTo(nameof(RecipeInfo.PreparationTime), 0));

            RuleFor(x => x.DifficultyLevel)
            .GreaterThanOrEqualTo(0)
            .WithMessage(ValidationMessages.GreaterThanOrEqualTo(nameof(RecipeInfo.PreparationTime), 0));

            RuleFor(x => x.DifficultyLevel)
            .LessThanOrEqualTo(5)
            .WithMessage(ValidationMessages.LowerThanOrEqualTo(nameof(RecipeInfo.PreparationTime), 5));
        }