msyavuz commented on code in PR #38711:
URL: https://github.com/apache/superset/pull/38711#discussion_r2954407892


##########
superset/reports/schemas.py:
##########
@@ -138,6 +141,34 @@ class ReportRecipientSchema(Schema):
     )
     recipient_config_json = fields.Nested(ReportRecipientConfigJSONSchema)
 
+    @validates_schema
+    def validate_email_recipients(self, data: dict[str, Any], **kwargs: Any) 
-> None:
+        if data.get("type") != ReportRecipientType.EMAIL.value:
+            return
+
+        config = data.get("recipient_config_json") or {}
+
+        def validate_addresses(field: str, value: str | None, required: bool) 
-> None:
+            if not value or not value.strip():
+                if required:
+                    raise ValidationError(
+                        {field: ["Email target is required for Email 
recipients"]}
+                    )
+                return
+            invalid = [
+                addr.strip()
+                for addr in re.split(r"[,;]", value)
+                if addr.strip() and not EMAIL_REGEX.match(addr.strip())

Review Comment:
   Should we add tests for the email validation?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to