From 5a8a1e27e100f3b807b4dcd0691959d3f8700c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20B=C3=B6ck?= <89930804+erikbocks@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:42:36 -0300 Subject: [PATCH] Fixed and enhanced vlan field validation in the UI (#10983) --- .../infra/zone/AdvancedGuestTrafficForm.vue | 59 +++++++++++++++---- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/ui/src/views/infra/zone/AdvancedGuestTrafficForm.vue b/ui/src/views/infra/zone/AdvancedGuestTrafficForm.vue index 4c0d2c137e6..caf690efcc9 100644 --- a/ui/src/views/infra/zone/AdvancedGuestTrafficForm.vue +++ b/ui/src/views/infra/zone/AdvancedGuestTrafficForm.vue @@ -39,6 +39,7 @@ { const values = toRaw(this.form) - if (!values.vlanRangeStart || (values.vlanRangeEnd && !this.checkFromTo(values.vlanRangeStart, values.vlanRangeEnd))) { + if (!this.checkFromTo(values.vlanRangeStart, values.vlanRangeEnd)) { this.validStatus = 'error' this.validMessage = this.$t('message.error.vlan.range') return @@ -185,19 +207,30 @@ export default { toVal = value fromVal = this.form[rule.compare] } - if (fromVal && toVal && !this.checkFromTo(fromVal, toVal)) { + if (!this.checkFromTo(fromVal, toVal)) { this.validStatus = 'error' this.validMessage = this.$t('message.error.vlan.range') } return Promise.resolve() }, checkFromTo (fromVal, toVal) { - if (!fromVal) fromVal = 0 - if (!toVal) toVal = 0 - if (fromVal > toVal) { - return false + const vlanRange = this.rangeLimits[this.isolationMethod] ? this.rangeLimits[this.isolationMethod] : this.rangeLimits.VLAN + switch (true) { + case ((fromVal === null) || (toVal === null)): + case fromVal === toVal: + case fromVal > toVal: + case toVal > vlanRange.max: + case fromVal < vlanRange.min: + return false + default: + this.validStatus = 'success' + this.validMessage = '' + return true } - return true + }, + getIsolationMethod () { + const phyNetworks = this.getPrefilled('physicalNetworks') + this.isolationMethod = phyNetworks[phyNetworks.length - 1].isolationMethod } } }