From 71aa45580d2c9d434e3c5fb06189ec98d56199fe Mon Sep 17 00:00:00 2001 From: Dixsie Date: Fri, 26 Mar 2021 12:38:03 -0500 Subject: 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 Change-Id: I4c8a21bbb9fec696c91a5cf3d2a7bf2e389cd566 --- .../NetworkSettings/NetworkSettings.vue | 37 ++++++++++------------ 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'src/views') 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 @@
{{ $t('global.form.fieldRequired') }}
-
+
{{ $t('global.form.invalidFormat') }}
@@ -90,7 +90,7 @@
{{ $t('global.form.fieldRequired') }}
-
+
{{ $t('global.form.invalidFormat') }}
@@ -221,7 +221,7 @@
{{ $t('global.form.invalidFormat') }} @@ -261,7 +261,7 @@
{{ $t('global.form.invalidFormat') }} @@ -335,7 +335,7 @@
{{ $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, }, }, }, -- cgit v1.2.3