diff --git a/src/Toolkit.js b/src/Toolkit.js index c730374..9a13ba5 100644 --- a/src/Toolkit.js +++ b/src/Toolkit.js @@ -121,6 +121,26 @@ Ext.apply(Ext.form.field.VTypes, { }, HttpProxyText: gettext('Example') + ": http://username:password@host:port/", + CpuSet: function(v) { + if (!Proxmox.Utils.CpuSet_match.test(v)) { + return false; + } + let groups = v.split(","); + for (let i = 0; i < groups.length; i++) { + if (!groups[i].includes("-")) { + continue; + } + let values = groups[i].split("-"); + let left = parseInt(values[0], 10); + let right = parseInt(values[1], 10); + if (left > right) { + return false; + } + } + return true; + }, + CpuSetText: gettext('This is not a valid CpuSet'), + DnsName: function(v) { return Proxmox.Utils.DnsName_match.test(v); }, diff --git a/src/Utils.js b/src/Utils.js index 6a03057..87afbea 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -1315,6 +1315,8 @@ utilities: { me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$"); me.DnsName_or_Wildcard_match = new RegExp("^(?:\\*\\.)?" + DnsName_REGEXP + "$"); + me.CpuSet_match = /^(?:(?:[0-9]+,)|(?:[0-9]+-[0-9]+,))*(?:(?:[0-9]+)$|(?:[0-9]+-[0-9]+)$)/; + me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(?::(\\d+))?$"); me.HostPortBrackets_match = new RegExp("^\\[(" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](?::(\\d+))?$"); me.IP6_dotnotation_match = new RegExp("^(" + IPV6_REGEXP + ")(?:\\.(\\d+))?$");