Skip to content

Commit 1aeddc6

Browse files
committed
Updated validation in RegisterProduct factory
1 parent 10c4f3f commit 1aeddc6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sample/Warehouse/Warehouse/Products/RegisteringProduct/RegisterProduct.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ private RegisterProduct(Guid productId, SKU sku, string name, string? descriptio
5757

5858
public static RegisterProduct Create(Guid? id, string? sku, string? name, string? description)
5959
{
60-
if (!id.HasValue) throw new ArgumentNullException(nameof(id));
61-
if (name == null) throw new ArgumentNullException(nameof(name));
60+
if (!id.HasValue || id == Guid.Empty) throw new ArgumentOutOfRangeException(nameof(id));
61+
if (string.IsNullOrEmpty(sku)) throw new ArgumentOutOfRangeException(nameof(sku));
62+
if (string.IsNullOrEmpty(name)) throw new ArgumentOutOfRangeException(nameof(name));
63+
if (description is "") throw new ArgumentOutOfRangeException(nameof(name));
6264

6365
return new RegisterProduct(id.Value, SKU.Create(sku), name, description);
6466
}

0 commit comments

Comments
 (0)