summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDixsie <dixsie@ibm.com>2021-03-26 20:38:03 +0300
committerDerick Montague <derick.montague@ibm.com>2021-04-06 04:16:58 +0300
commit71aa45580d2c9d434e3c5fb06189ec98d56199fe (patch)
tree6408a66ccb815f10476e2104cc20aae9b29080ee
parent1915d8c4992c1a4165e8ae108e4d799b3b4ce86a (diff)
downloadwebui-vue-71aa45580d2c9d434e3c5fb06189ec98d56199fe.tar.xz
Fix network setting validations bug
Removed regex vuelidate validation helpers for IP address and MAC address and used builtin vuelidate validators for each. Using builtin validators reduces human error when using custom validators. The regex helpers were incorrect and causing validation errors. Signed-off-by: Dixsie Wolmers <dixsie@ibm.com> Change-Id: I4c8a21bbb9fec696c91a5cf3d2a7bf2e389cd566
-rw-r--r--src/views/Configuration/NetworkSettings/NetworkSettings.vue37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/views/Configuration/NetworkSettings/NetworkSettings.vue b/src/views/Configuration/NetworkSettings/NetworkSettings.vue
index f007a94c..d6da7177 100644
--- a/src/views/Configuration/NetworkSettings/NetworkSettings.vue
+++ b/src/views/Configuration/NetworkSettings/NetworkSettings.vue
@@ -42,7 +42,7 @@
<div v-if="!$v.form.gateway.required">
{{ $t('global.form.fieldRequired') }}
</div>
- <div v-if="!$v.form.gateway.validateAddress">
+ <div v-if="!$v.form.gateway.ipAddress">
{{ $t('global.form.invalidFormat') }}
</div>
</b-form-invalid-feedback>
@@ -90,7 +90,7 @@
<div v-if="!$v.form.macAddress.required">
{{ $t('global.form.fieldRequired') }}
</div>
- <div v-if="!$v.form.macAddress.validateMacAddress">
+ <div v-if="!$v.form.macAddress.macAddress">
{{ $t('global.form.invalidFormat') }}
</div>
</b-form-invalid-feedback>
@@ -221,7 +221,7 @@
<div
v-if="
!$v.form.ipv4StaticTableItems.$each.$iter[index].Address
- .validateAddress
+ .ipAddress
"
>
{{ $t('global.form.invalidFormat') }}
@@ -261,7 +261,7 @@
<div
v-if="
!$v.form.ipv4StaticTableItems.$each.$iter[index]
- .SubnetMask.validateAddress
+ .SubnetMask.ipAddress
"
>
{{ $t('global.form.invalidFormat') }}
@@ -335,7 +335,7 @@
<div
v-if="
!$v.form.dnsStaticTableItems.$each.$iter[index].address
- .validateAddress
+ .ipAddress
"
>
{{ $t('global.form.invalidFormat') }}
@@ -384,20 +384,15 @@ import PageTitle from '@/components/Global/PageTitle';
import TableRowAction from '@/components/Global/TableRowAction';
import VuelidateMixin from '@/components/Mixins/VuelidateMixin';
import { mapState } from 'vuex';
-import { required, helpers } from 'vuelidate/lib/validators';
+import {
+ required,
+ helpers,
+ ipAddress,
+ macAddress,
+} from 'vuelidate/lib/validators';
-// IP address, gateway and subnet pattern
-const validateAddress = helpers.regex(
- 'validateAddress',
- /^(?=.*[^.]$)((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.?){4}$/
-);
// Hostname pattern
const validateHostname = helpers.regex('validateHostname', /^\S{0,64}$/);
-// MAC address pattern
-const validateMacAddress = helpers.regex(
- 'validateMacAddress',
- /^(?:[0-9A-Fa-f]{2}([:-]?)[0-9A-Fa-f]{2})(?:(?:\1|\.)(?:[0-9A-Fa-f]{2}([:-]?)[0-9A-Fa-f]{2})){2}$/
-);
export default {
name: 'NetworkSettings',
@@ -461,26 +456,26 @@ export default {
validations() {
return {
form: {
- gateway: { required, validateAddress },
+ gateway: { required, ipAddress },
hostname: { required, validateHostname },
ipv4StaticTableItems: {
$each: {
Address: {
required,
- validateAddress,
+ ipAddress,
},
SubnetMask: {
required,
- validateAddress,
+ ipAddress,
},
},
},
- macAddress: { required, validateMacAddress },
+ macAddress: { required, macAddress: macAddress() },
dnsStaticTableItems: {
$each: {
address: {
required,
- validateAddress,
+ ipAddress,
},
},
},