internal AndroidNotification CopyAndValidate()

in FirebaseAdmin/FirebaseAdmin/Messaging/AndroidNotification.cs [125:164]


        internal AndroidNotification CopyAndValidate()
        {
            var copy = new AndroidNotification()
            {
                Title = this.Title,
                Body = this.Body,
                Icon = this.Icon,
                Color = this.Color,
                Sound = this.Sound,
                Tag = this.Tag,
                ImageUrl = this.ImageUrl,
                ClickAction = this.ClickAction,
                TitleLocKey = this.TitleLocKey,
                TitleLocArgs = this.TitleLocArgs?.ToList(),
                BodyLocKey = this.BodyLocKey,
                BodyLocArgs = this.BodyLocArgs?.ToList(),
                ChannelId = this.ChannelId,
            };
            if (copy.Color != null && !Regex.Match(copy.Color, "^#[0-9a-fA-F]{6}$").Success)
            {
                throw new ArgumentException("Color must be in the form #RRGGBB.");
            }

            if (copy.TitleLocArgs?.Any() == true && string.IsNullOrEmpty(copy.TitleLocKey))
            {
                throw new ArgumentException("TitleLocKey is required when specifying TitleLocArgs.");
            }

            if (copy.BodyLocArgs?.Any() == true && string.IsNullOrEmpty(copy.BodyLocKey))
            {
                throw new ArgumentException("BodyLocKey is required when specifying BodyLocArgs.");
            }

            if (copy.ImageUrl != null && !Uri.IsWellFormedUriString(copy.ImageUrl, UriKind.Absolute))
            {
                throw new ArgumentException($"Malformed image URL string: {copy.ImageUrl}.");
            }

            return copy;
        }