Skip to content

New Validation Logic#39

Open
robinmanuelthiel wants to merge 1 commit intomainfrom
feat-new-validation
Open

New Validation Logic#39
robinmanuelthiel wants to merge 1 commit intomainfrom
feat-new-validation

Conversation

@robinmanuelthiel
Copy link
Owner

@robinmanuelthiel robinmanuelthiel commented Jul 2, 2025

This pull request introduces a validation improvement to the BasketItem model in the Basket.API project. It adds a new condition to ensure that the OldUnitPrice is not greater than or equal to the UnitPrice.

Validation improvements:

  • src/Basket.API/Model/BasketItem.cs: Added a validation check to the Validate method that triggers an error message ("Der Preis ist zu heiß!") if OldUnitPrice is greater than or equal to UnitPrice.

@robinmanuelthiel robinmanuelthiel requested a review from Copilot July 2, 2025 12:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new rule to validate that the old unit price is lower than the current unit price.

  • Introduces a check in BasketItem.Validate to compare OldUnitPrice and UnitPrice
  • Returns a validation error when the price rule is violated
Comments suppressed due to low confidence (1)

src/Basket.API/Model/BasketItem.cs:22

  • Add unit tests for this new validation rule to ensure it correctly enforces that OldUnitPrice < UnitPrice under various scenarios.
        if (OldUnitPrice >= UnitPrice)


if (OldUnitPrice >= UnitPrice)
{
results.Add(new ValidationResult("Der Preis ist zu heiß!", new[] { "OldUnitPrice", "UnitPrice" }));
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message is in German and inconsistent with the existing English messages; consider using a clear English message like "UnitPrice must be greater than OldUnitPrice".

Suggested change
results.Add(new ValidationResult("Der Preis ist zu heiß!", new[] { "OldUnitPrice", "UnitPrice" }));
results.Add(new ValidationResult("UnitPrice must be greater than OldUnitPrice", new[] { "OldUnitPrice", "UnitPrice" }));

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants