From: Stoiko Ivanov Date: Wed, 23 Nov 2022 09:23:35 +0000 (+0100) Subject: utils: add custom validator for pmg-email-address X-Git-Url: https://git.proxmox.com/?p=pmg-gui.git;a=commitdiff_plain;h=845efd4177eef0973ad2e9fcc2c5d320b9d262a5 utils: add custom validator for pmg-email-address matching the pattern in the backend (allowing most characters inside of e-mail addresses. Signed-off-by: Stoiko Ivanov --- 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@example.com", +});