X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FJSONSchema.pm;fp=src%2FPVE%2FJSONSchema.pm;h=20d72b317e801799bbc78f2f19c82ca126a73221;hp=5870b69507ac718823d74a57168afc893987c52e;hb=ff8d3b1d7ae5fb6f8b509c25dcaa5136bb193dc5;hpb=4c4bd1047c7ff96a5eec4ed5ea4f3337b750a3e6 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) = @_;