[pmg-devel] [PATCH widget-toolkit 1/1] add DnsOrIp vtype

Dominik Csapak d.csapak at proxmox.com
Wed Mar 13 15:17:09 CET 2019


this is useful for options that can be dns names or ips (e.g. ldap servers)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 Toolkit.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Toolkit.js b/Toolkit.js
index 4f1b623..bb9157f 100644
--- a/Toolkit.js
+++ b/Toolkit.js
@@ -108,6 +108,17 @@ Ext.apply(Ext.form.field.VTypes, {
     },
     proxmoxMailText: gettext('Example') + ": user at example.com",
 
+    DnsOrIp: function(v) {
+	if (!Proxmox.Utils.DnsName_match.test(v) &&
+	    !Proxmox.Utils.IP64_match.test(v))
+	{
+	    return false;
+	}
+
+	return true;
+    },
+    DnsOrIpText: gettext('Not a valid DNS name or IP Address.'),
+
     HostList: function(v) {
 	var list = v.split(/[\ \,\;]+/);
 	var i;
-- 
2.11.0




More information about the pmg-devel mailing list