public static PhoneNumberVO Create(PhoneNumberTypeEnum type, string value) { var instance = new PhoneNumberVO { Type = type, Value = value }; ValidateInstance(instance); return(instance); }
public static void ValidateInstance(PhoneNumberVO instance) { if ( instance.Type == default || string.IsNullOrWhiteSpace(instance.Value) || !Enumerable.Range(4, 50).Contains(instance.Value.Length) || !Regex.Match(instance.Value, "^([0-9]+)$", RegexOptions.IgnoreCase).Success ) { throw new DomainException(DomainExceptionCode.InvalidPhoneNumber); } }