Skip to content

Commit

Permalink
Updated validation in RegisterProduct factory
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed May 24, 2021
1 parent 10c4f3f commit 1aeddc6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ private RegisterProduct(Guid productId, SKU sku, string name, string? descriptio

public static RegisterProduct Create(Guid? id, string? sku, string? name, string? description)
{
if (!id.HasValue) throw new ArgumentNullException(nameof(id));
if (name == null) throw new ArgumentNullException(nameof(name));
if (!id.HasValue || id == Guid.Empty) throw new ArgumentOutOfRangeException(nameof(id));
if (string.IsNullOrEmpty(sku)) throw new ArgumentOutOfRangeException(nameof(sku));
if (string.IsNullOrEmpty(name)) throw new ArgumentOutOfRangeException(nameof(name));
if (description is "") throw new ArgumentOutOfRangeException(nameof(name));

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

0 comments on commit 1aeddc6

Please sign in to comment.