Exemplo n.º 1
0
 public static AddressOO Create(
     NonEmptyStringOO street,
     NonEmptyStringOO city,
     ZipcodeOO zipcode)
 {
     return(new AddressOO(street, city, zipcode));
 }
Exemplo n.º 2
0
        public static Option <ZipcodeOO> Create(string potentialZipcode)
        {
            var option = NonEmptyStringOO.Create(potentialZipcode);

            return(option.Match(
                       () => F.None,
                       Create));
        }
Exemplo n.º 3
0
        private ZipcodeOO(NonEmptyStringOO potentialZipcode)
        {
            if (!IsValid(potentialZipcode))
            {
                throw new ArgumentException($"Invalid zip code! {potentialZipcode}");
            }

            Value = potentialZipcode.Value;
        }
Exemplo n.º 4
0
        public static Option <ZipcodeOO> Create(NonEmptyStringOO potentialZipcode)
        {
            Option <ZipcodeOO> result;

            try
            {
                result = F.Some(new ZipcodeOO(potentialZipcode));
            }
            catch (Exception)
            {
                result = F.None;
            }

            return(result);
        }
Exemplo n.º 5
0
 public static ZipcodeOO CreateBang(string potentialZipcode)
 {
     return(new ZipcodeOO(NonEmptyStringOO.CreateBang(potentialZipcode)));
 }
Exemplo n.º 6
0
 // Just another rule..
 private static bool IsValid(NonEmptyStringOO potentialZipcode) =>
 potentialZipcode.Value.Length >= 3;
Exemplo n.º 7
0
 private AddressOO(NonEmptyStringOO street, NonEmptyStringOO city, ZipcodeOO zipcode)
 {
     Street  = street;
     City    = city;
     Zipcode = zipcode;
 }