From 26260e6619abdeb2d8bfb7c7972468c43eef8699 Mon Sep 17 00:00:00 2001 From: vishwajeet-13 Date: Fri, 8 May 2026 00:19:24 +0530 Subject: [PATCH 1/2] feat: validate phone field --- buzz/api/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/buzz/api/__init__.py b/buzz/api/__init__.py index 06e636e..590d074 100644 --- a/buzz/api/__init__.py +++ b/buzz/api/__init__.py @@ -317,6 +317,14 @@ def get_event_booking_data(event_route: str) -> dict: return data +def validate_custom_fields(custom_fields_data: dict, phone_field_map: dict) -> None: + for field_name, field_value in custom_fields_data.items(): + if field_value and field_name in phone_field_map: + frappe.utils.validate_phone_number_with_country_code( + str(field_value), phone_field_map[field_name] + ) + + @frappe.whitelist(allow_guest=True) # nosemgrep: frappe-semgrep-rules.rules.security.guest-whitelisted-method def process_booking( attendees: list[dict], @@ -416,6 +424,16 @@ def process_booking( "fieldtype": field_def["fieldtype"], }, ) + + phone_fields = frappe.db.get_all( + "Buzz Custom Field", + filters={"event": event, "enabled": 1, "fieldtype": "Phone"}, + fields=["fieldname", "label"], + ) + phone_map = {cf["fieldname"]: cf["label"] for cf in phone_fields} + + if booking_custom_fields: + validate_custom_fields(booking_custom_fields, phone_map) if event_doc.category == "Webinars": for attendee in attendees: if not (attendee.get("last_name") or "").strip(): @@ -440,6 +458,8 @@ def process_booking( ) custom_fields = attendee.get("custom_fields", {}) + if custom_fields: + validate_custom_fields(custom_fields, phone_map) attendee_row = { "first_name": first_name, "last_name": last_name, From 84cdc576c7f1495cd3bacebc4dde760aca1abab3 Mon Sep 17 00:00:00 2001 From: vishwajeet-13 Date: Fri, 8 May 2026 11:19:56 +0530 Subject: [PATCH 2/2] fix: remove in booking level --- buzz/api/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/buzz/api/__init__.py b/buzz/api/__init__.py index 590d074..06fc381 100644 --- a/buzz/api/__init__.py +++ b/buzz/api/__init__.py @@ -432,8 +432,6 @@ def process_booking( ) phone_map = {cf["fieldname"]: cf["label"] for cf in phone_fields} - if booking_custom_fields: - validate_custom_fields(booking_custom_fields, phone_map) if event_doc.category == "Webinars": for attendee in attendees: if not (attendee.get("last_name") or "").strip():