From b5b9cc81a50588f73ca440e3ec514e60e21c9089 Mon Sep 17 00:00:00 2001 From: Tyler Koenig Date: Sun, 24 May 2026 17:38:40 -0400 Subject: [PATCH] fix(tui): skip irrelevant field validation by monitor type URL, SSL threshold, and port validators blocked form progression when editing monitors that don't use those fields (e.g. ping monitors failing URL validation, non-SSL sites failing threshold check). Scope each validator to fire only for its relevant monitor type. --- internal/tui/tab_sites.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/tui/tab_sites.go b/internal/tui/tab_sites.go index eac0978..6aa6f3a 100644 --- a/internal/tui/tab_sites.go +++ b/internal/tui/tab_sites.go @@ -509,7 +509,7 @@ func (m *Model) initSiteHuhForm() tea.Cmd { Description("Required for HTTP monitors"). Value(&m.siteFormData.URL). Validate(func(s string) error { - if m.siteFormData.SiteType == "push" || m.siteFormData.SiteType == "group" { + if m.siteFormData.SiteType != "http" { return nil } if s == "" { @@ -555,12 +555,15 @@ func (m *Model) initSiteHuhForm() tea.Cmd { Description("Target port for TCP port monitors"). Value(&m.siteFormData.Port). Validate(func(s string) error { + if m.siteFormData.SiteType != "port" { + return nil + } v, err := strconv.Atoi(s) if err != nil { return fmt.Errorf("must be a number") } - if v < 0 || v > 65535 { - return fmt.Errorf("port must be 0-65535") + if v < 1 || v > 65535 { + return fmt.Errorf("port must be 1-65535") } return nil }), @@ -615,6 +618,9 @@ func (m *Model) initSiteHuhForm() tea.Cmd { Placeholder("7"). Value(&m.siteFormData.Threshold). Validate(func(s string) error { + if !m.siteFormData.CheckSSL { + return nil + } v, err := strconv.Atoi(s) if err != nil { return fmt.Errorf("must be a number")