From df0c683c6c2a567e48efef4f751249cfee01da5d Mon Sep 17 00:00:00 2001 From: Kunhui-Li Date: Mon, 4 Jul 2022 11:04:49 +0800 Subject: [PATCH] config_tools: apply pattern check to interface name This patch applies pattern check to network interface name. Report error if regex doesn't match. Tracked-On: #6690 Signed-off-by: Kunhui-Li --- .../Config/ConfigForm/CustomWidget/Virtio/Network.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue index c29145d15..f5eeaa4f0 100644 --- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue +++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue @@ -17,7 +17,10 @@ - + + + An arbitrary-long string with letters, digits, underscores or dashes. + @@ -67,6 +70,7 @@ export default { }, data() { return { + NetworkConfiguration: this.rootSchema.definitions['VirtioNetworkConfiguration'], NetworkFrameworkType: this.rootSchema.definitions['VirtioNetworkFrameworkType']['enum'], NetworkFrameworkDefault: this.rootSchema.definitions['VirtioNetworkConfiguration']['properties']['virtio_framework']['default'], defaultVal: vueUtils.getPathVal(this.rootFormData, this.curNodePath) @@ -90,6 +94,10 @@ export default { } }, methods: { + validateInterfaceName(value) { + var regexp = new RegExp(this.NetworkConfiguration.properties.interface_name.pattern); + return (value != null) && regexp.test(value); + }, removeVirtioNetwork(index) { this.defaultVal.splice(index, 1); },