[pve-devel] r6223 - in pve-common/trunk/data: . PVE
svn-commits at proxmox.com
svn-commits at proxmox.com
Mon Jul 4 08:10:34 CEST 2011
Author: dietmar
Date: 2011-07-04 08:10:34 +0200 (Mon, 04 Jul 2011)
New Revision: 6223
Modified:
pve-common/trunk/data/ChangeLog
pve-common/trunk/data/PVE/JSONSchema.pm
Log:
allow to add '-opt' to format
specifier which allows to pass empty strings. For
example format 'email' always requires a valid email address,
whereas format 'email-opt' also accepts an emtpy string.
Modified: pve-common/trunk/data/ChangeLog
===================================================================
--- pve-common/trunk/data/ChangeLog 2011-07-04 05:53:05 UTC (rev 6222)
+++ pve-common/trunk/data/ChangeLog 2011-07-04 06:10:34 UTC (rev 6223)
@@ -1,3 +1,10 @@
+2011-07-04 Proxmox Support Team <support at proxmox.com>
+
+ * PVE/JSONSchema.pm (check_format): allow to add '-opt' to format
+ specifier which allows to pass empty strings. For
+ example format 'email' always requires a valid email address,
+ whereas format 'email-opt' also accepts an emtpy string.
+
2011-06-21 Proxmox Support Team <support at proxmox.com>
* PVE/Tools.pm (run_command): use alarm to impl. timeout
Modified: pve-common/trunk/data/PVE/JSONSchema.pm
===================================================================
--- pve-common/trunk/data/PVE/JSONSchema.pm 2011-07-04 05:53:05 UTC (rev 6222)
+++ pve-common/trunk/data/PVE/JSONSchema.pm 2011-07-04 06:10:34 UTC (rev 6223)
@@ -176,8 +176,18 @@
&$code($v);
}
- } else {
+ } elsif ($format =~ m/^(.*)-opt$/) {
+ my $code = $format_list->{$1};
+
+ die "undefined format '$format'\n" if !$code;
+
+ return if !$value; # allow empty string
+
+ &$code($value);
+
+ } else {
+
my $code = $format_list->{$format};
die "undefined format '$format'\n" if !$code;
More information about the pve-devel
mailing list