Newer
Older
Warehouse / src / Domain / Partners / Address.cs
@Derek Comartin Derek Comartin on 22 Aug 2023 868 bytes Init
namespace MyWarehouse.Domain.Partners;

/// <summary>
/// Value object representing an address.
/// </summary>
public record Address
{
    [Required, MinLength(1), MaxLength(100)]
    public string Street { get; init; }

    [Required, MinLength(1), MaxLength(100)]
    public string City { get; init; }

    [Required, MinLength(1), MaxLength(100)]
    public string Country { get; init; }

    [Required, MinLength(1), MaxLength(100)]
    public string ZipCode { get; init; }

    private Address()
    {
        Street = City = Country = ZipCode = default!;
    }

    // TODO: Add validation and constraints
    public Address(string street, string city, string country, string zipcode)
        => (Street, City, Country, ZipCode) = (street, city, country, zipcode);

    public override string ToString()
        => $"{Street}, {ZipCode} {City}, {Country}";
}