Skip to content

Instantly share code, notes, and snippets.

@maiconheck
Last active June 20, 2023 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maiconheck/810e2cf01a4d38e694d29758d8fcaa53 to your computer and use it in GitHub Desktop.
Save maiconheck/810e2cf01a4d38e694d29758d8fcaa53 to your computer and use it in GitHub Desktop.
public class Address
{
public Address(string zipCode, string street, int number, string neighborhood, string complement = "")
{
Guard.Against
.NotMatch(zipCode, @"^\d{5}-\d{3}$", nameof(zipCode))
.NullOrWhiteSpace(street, nameof(street))
.ZeroOrLess(number, nameof(number))
.NullOrWhiteSpace(neighborhood, nameof(neighborhood));
ZipCode = zipCode;
Street = street;
Number = number;
Neighborhood = neighborhood;
Complement = complement;
}
public string ZipCode { get; }
public string Street { get; }
public int Number { get; }
public string Neighborhood { get; }
public string Complement { get; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment