Skip to content

Commit

Permalink
Notification setup: Improve validation of step 4
Browse files Browse the repository at this point in the history
CMK-19993

Change-Id: I720aef6ef3ef487476739a35418d47e29badd039
  • Loading branch information
makanakoeln committed Nov 25, 2024
1 parent 5150410 commit a766728
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions cmk/gui/wato/pages/notifications/quick_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
TimeMagnitude,
TimeSpan,
)
from cmk.rulesets.v1.form_specs.validators import EmailAddress, ValidationError
from cmk.rulesets.v1.form_specs.validators import EmailAddress, LengthInRange, ValidationError

NEXT_BUTTON_ARIA_LABEL = _("Go to the next stage")
PREV_BUTTON_ARIA_LABEL = _("Go to the previous stage")
Expand Down Expand Up @@ -1150,6 +1150,14 @@ def _components() -> Sequence[Widget]:
),
single_choice_type=SingleChoice,
elements=_contact_group_choice(),
custom_validate=[
LengthInRange(
min_value=1,
error_msg=Message(
"Please add at least one contact group"
),
)
],
),
),
),
Expand All @@ -1160,8 +1168,16 @@ def _components() -> Sequence[Widget]:
parameter_form=ListOfStrings(
layout=ListOfStringsLayout.vertical,
string_spec=String(
custom_validate=[EmailAddress()]
custom_validate=[EmailAddress()],
),
custom_validate=[
LengthInRange(
min_value=1,
error_msg=Message(
"Please add at least one email address"
),
),
],
),
),
),
Expand All @@ -1184,6 +1200,14 @@ def _components() -> Sequence[Widget]:
)
for ident, title in _get_sorted_users()
],
custom_validate=[
LengthInRange(
min_value=1,
error_msg=Message(
"Please add at least one user"
),
),
],
),
),
),
Expand Down Expand Up @@ -1223,6 +1247,14 @@ def _components() -> Sequence[Widget]:
),
single_choice_type=SingleChoice,
elements=_contact_group_choice(),
custom_validate=[
LengthInRange(
min_value=1,
error_msg=Message(
"Please add at least one contact group"
),
),
],
),
),
),
Expand All @@ -1247,6 +1279,14 @@ def _components() -> Sequence[Widget]:
],
),
add_element_label=Label("Add condition"),
custom_validate=[
LengthInRange(
min_value=1,
error_msg=Message(
"Please add at least one macro"
),
),
],
),
),
),
Expand Down

0 comments on commit a766728

Please sign in to comment.