[pve-devel] [PATCH v2 common 2/8] register email-or-username format
Fabian Ebner
f.ebner at proxmox.com
Mon Feb 15 13:24:56 CET 2021
To be used for the mailto vzdump parameter.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
New in v2.
src/PVE/JSONSchema.pm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 5870b69..20d72b3 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -478,6 +478,18 @@ sub pve_verify_email {
return $email;
}
+register_format('email-or-username', \&pve_verify_email_or_username);
+sub pve_verify_email_or_username {
+ my ($email, $noerr) = @_;
+
+ if ($email !~ /^$PVE::Tools::EMAIL_RE$/ &&
+ $email !~ /^$PVE::Tools::EMAIL_USER_RE$/) {
+ return undef if $noerr;
+ die "value does not look like a valid email address or user name\n";
+ }
+ return $email;
+}
+
register_format('dns-name', \&pve_verify_dns_name);
sub pve_verify_dns_name {
my ($name, $noerr) = @_;
--
2.20.1
More information about the pve-devel
mailing list