X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2FPVE%2FJSONSchema.pm;h=71df690b56d846795d556583509639ed8d01461f;hb=d94f7005cee0677d186f67b5641cd4a96824477c;hp=0b2db2dcb4563f320e9110fc33eca34f26cef1ed;hpb=6ab98c4e537099162919ac75f3f767e406d84bec;p=pve-common.git diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index 0b2db2d..71df690 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -689,6 +689,18 @@ sub pve_verify_tfa_secret { die "unable to decode TFA secret\n"; } + +PVE::JSONSchema::register_format('pve-task-status-type', \&verify_task_status_type); +sub verify_task_status_type { + my ($value, $noerr) = @_; + + return $value if $value =~ m/^(ok|error|warning|unknown)$/i; + + return undef if $noerr; + + die "invalid status '$value'\n"; +} + sub check_format { my ($format, $value, $path) = @_; @@ -714,13 +726,14 @@ sub check_format { if $format_type ne 'none' && ref($registered) ne 'CODE'; if ($format_type eq 'list') { + $parsed = []; # Note: we allow empty lists foreach my $v (split_list($value)) { - $parsed = $registered->($v); + push @{$parsed}, $registered->($v); } } elsif ($format_type eq 'opt') { $parsed = $registered->($value) if $value; - } else { + } else { if (ref($registered) eq 'HASH') { # Note: this is the only case where a validator function could be # attached, hence it's safe to handle that in parse_property_string.