From 7ad4b043439f9195d8f14f7ee41032c1af572419 Mon Sep 17 00:00:00 2001 From: Ronny Bruska Date: Fri, 10 Jan 2025 13:42:50 +0100 Subject: [PATCH] Notifications: Fix mandatory documentation URL Change-Id: I829d125ba1ec03b17b2f238d4e7acd24898166d4 --- cmk/gui/wato/pages/notifications/quick_setup.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmk/gui/wato/pages/notifications/quick_setup.py b/cmk/gui/wato/pages/notifications/quick_setup.py index 798707d80b2..2212e94b9fd 100644 --- a/cmk/gui/wato/pages/notifications/quick_setup.py +++ b/cmk/gui/wato/pages/notifications/quick_setup.py @@ -1514,9 +1514,7 @@ def _components() -> Sequence[Widget]: parameter_form=String( title=Title("Documentation URL"), field_size=FieldSize.LARGE, - custom_validate=[ - Url(protocols=[UrlProtocol.HTTP, UrlProtocol.HTTPS]), - ], + custom_validate=[_validate_optional_url], ), ), }, @@ -1543,6 +1541,14 @@ def _components() -> Sequence[Widget]: ) +def _validate_optional_url(value: str) -> None: + if not value: + return + + url_validator_instance = Url(protocols=[UrlProtocol.HTTP, UrlProtocol.HTTPS]) + url_validator_instance(value) + + def save_and_test_action( all_stages_form_data: ParsedFormData, mode: QuickSetupActionMode, object_id: str | None ) -> str: