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

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

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