[pmg-devel] [PATCH pmg-gui v3 1/2] utils: add custom validator for pmg-email-address

Stoiko Ivanov s.ivanov at proxmox.com
Wed Nov 23 10:23:35 CET 2022


matching the pattern in the backend (allowing most characters inside
of e-mail addresses.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 js/UserBlackWhiteList.js | 2 +-
 js/Utils.js              | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/js/UserBlackWhiteList.js b/js/UserBlackWhiteList.js
index 4f4a756..44d75b3 100644
--- a/js/UserBlackWhiteList.js
+++ b/js/UserBlackWhiteList.js
@@ -127,7 +127,7 @@ Ext.define('PMG.UserBlackWhiteList', {
 	{
 	    xtype: 'combobox',
 	    displayField: 'mail',
-	    vtype: 'email',
+	    vtype: 'proxmoxMail',
 	    allowBlank: false,
 	    valueField: 'mail',
 	    store: {
diff --git a/js/Utils.js b/js/Utils.js
index dc924d2..7fa154e 100644
--- a/js/Utils.js
+++ b/js/Utils.js
@@ -898,3 +898,12 @@ Ext.define('PMG.Async', {
 	);
     },
 });
+
+// custom Vtypes
+Ext.apply(Ext.form.field.VTypes, {
+    // matches the pmg-email-address in pmg-api
+    PMGMail: function(v) {
+	return (/[^\s\\@]+@[^\s/\\@]+/).test(v);
+    },
+    PMGMailText: gettext('Example') + ": user at example.com",
+});
-- 
2.30.2





More information about the pmg-devel mailing list