config_tools: apply pattern check to virtio input id

this patch applies pattern check to virtio input id. Report error if
regex doesn't match.

Tracked-On: #6690
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
This commit is contained in:
Kunhui-Li 2022-07-04 11:17:59 +08:00 committed by acrnsi-robot
parent df0c683c6c
commit 39626609d0
1 changed files with 9 additions and 1 deletions

View File

@ -17,7 +17,10 @@
Guest virtio input device unique identifier:
</b-col>
<b-col md="4">
<b-form-input v-model="input.id"/>
<b-form-input :state="validateId(input.id)" v-model="input.id" placeholder="An arbitrary-long string with letters, digits, underscores or dashes."/>
<b-form-invalid-feedback>
An arbitrary-long string with letters, digits, underscores or dashes.
</b-form-invalid-feedback>
</b-col>
</b-row>
</div>
@ -67,6 +70,7 @@ export default {
},
data() {
return {
InputConfiguration: this.rootSchema.definitions['VirtioInputConfiguration'],
BackendDeviceFileType: this.rootSchema.definitions['VirtioInputConfiguration']['properties']['backend_device_file']['enum'],
defaultVal: vueUtils.getPathVal(this.rootFormData, this.curNodePath)
};
@ -89,6 +93,10 @@ export default {
}
},
methods: {
validateId(value) {
var regexp = new RegExp(this.InputConfiguration.properties.id.pattern);
return (value != null) && regexp.test(value);
},
removeVirtioInput(index) {
this.defaultVal.splice(index, 1);
},