sub pve_verify_email {
my ($email, $noerr) = @_;
- # we use same regex as extjs Ext.form.VTypes.email
- if ($email !~ /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/) {
+ # we use same regex as in Utils.js
+ if ($email !~ /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,63}$/) {
return undef if $noerr;
die "value does not look like a valid email address\n";
}
optional => 1,
description => "This provides a description of the purpose the instance property. The value can be a string or it can be an object with properties corresponding to various different instance languages (with an optional default property indicating the default description).",
},
+ format_description => {
+ type => "string",
+ optional => 1,
+ description => "This provides a shorter (usually just one word) description for a property used to generate descriptions for comma separated list property strings.",
+ },
title => {
type => "string",
optional => 1,
description => "JSON Schema for parameters.",
optional => 1,
},
+ formatter => {
+ type => 'object',
+ description => "Used to store page formatter information (set by PVE::RESTHandler->register_page_formatter).",
+ optional => 1,
+ },
returns => {
type => 'object',
description => "JSON Schema for return value.",
return $data;
}
+sub generate_typetext {
+ my ($schema) = @_;
+ my $typetext = '';
+ my (@optional, @required);
+ foreach my $key (sort keys %$schema) {
+ next if !$schema->{$key}->{format_description};
+ if ($schema->{$key}->{optional}) {
+ push @optional, $key;
+ } else {
+ push @required, $key;
+ }
+ }
+ my ($pre, $post) = ('', '');
+ foreach my $key (@required) {
+ my $desc = $schema->{$key}->{format_description};
+ $typetext .= "$pre$key=<$desc>$post";
+ $pre = ', ';
+ }
+ $pre = ' [,' if $pre;
+ foreach my $key (@optional) {
+ my $desc = $schema->{$key}->{format_description};
+ $typetext .= "$pre$key=<$desc>$post";
+ $pre = ' [,';
+ $post = ']';
+ }
+ return $typetext;
+}
+
1;