public static AddressOO Create( NonEmptyStringOO street, NonEmptyStringOO city, ZipcodeOO zipcode) { return(new AddressOO(street, city, zipcode)); }
public static Option <ZipcodeOO> Create(string potentialZipcode) { var option = NonEmptyStringOO.Create(potentialZipcode); return(option.Match( () => F.None, Create)); }
private ZipcodeOO(NonEmptyStringOO potentialZipcode) { if (!IsValid(potentialZipcode)) { throw new ArgumentException($"Invalid zip code! {potentialZipcode}"); } Value = potentialZipcode.Value; }
public static Option <ZipcodeOO> Create(NonEmptyStringOO potentialZipcode) { Option <ZipcodeOO> result; try { result = F.Some(new ZipcodeOO(potentialZipcode)); } catch (Exception) { result = F.None; } return(result); }
public static ZipcodeOO CreateBang(string potentialZipcode) { return(new ZipcodeOO(NonEmptyStringOO.CreateBang(potentialZipcode))); }
// Just another rule.. private static bool IsValid(NonEmptyStringOO potentialZipcode) => potentialZipcode.Value.Length >= 3;
private AddressOO(NonEmptyStringOO street, NonEmptyStringOO city, ZipcodeOO zipcode) { Street = street; City = city; Zipcode = zipcode; }