Пример #1
0
        public static PhoneNumberVO Create(PhoneNumberTypeEnum type, string value)
        {
            var instance = new PhoneNumberVO {
                Type = type, Value = value
            };

            ValidateInstance(instance);

            return(instance);
        }
Пример #2
0
 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);
     }
 }