using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace LinqSqlEpisodeIVProVid
{
    public partial class Customer
    {
        partial void OnPhoneChanging(string value)
        {
            Regex phoneNumber = new Regex(@"^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$");
            if (phoneNumber.IsMatch(value) == false)
            {
                throw new ArgumentException("Invalid Phone Number");
            }
        }
    }
}
