Skip to content

Commit

Permalink
Add child product validation
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepdeJong committed Sep 20, 2024
1 parent 7d01c3a commit bdac91e
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ private void assertIsValidProduct(Product product) throws ProductInvalidExceptio
if (product.getParentProduct() == null && (product.getMaxSoldPerCustomer() == null || product.getMaxSoldPerCustomer() < 1 || product.getMaxSoldPerCustomer() > 25)) {
throw new ProductInvalidException("Max sold per customer should be between 1 and 25!");
}

if (product.getParentProduct() != null && product.getChildProducts() != null && product.getChildProducts().size() > 0) {
throw new ProductInvalidException("A product can not have a parent product and be a parent product at the same time!");
}
}

/**
Expand Down

0 comments on commit bdac91e

Please sign in to comment.