]> git.proxmox.com Git - pve-common.git/commitdiff
JSONSchema: use validator in print_property_string too
authorStefan Reiter <s.reiter@proxmox.com>
Thu, 25 Jun 2020 11:35:40 +0000 (13:35 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 6 Jul 2020 08:40:10 +0000 (10:40 +0200)
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/PVE/JSONSchema.pm

index de2261e5a91c343fa5e19ee1b37b2cf23c0ebff4..c5002d83036209592562bd947fea10418c76fdb0 100644 (file)
@@ -1897,9 +1897,12 @@ sub generate_typetext {
 sub print_property_string {
     my ($data, $format, $skip, $path) = @_;
 
+    my $validator;
     if (ref($format) ne 'HASH') {
        my $schema = get_format($format);
        die "not a valid format: $format\n" if !$schema;
+       # named formats can have validators attached
+       $validator = $format_validators->{$format};
        $format = $schema;
     }
 
@@ -1909,6 +1912,8 @@ sub print_property_string {
        raise "format error", errors => $errors;
     }
 
+    $data = $validator->($data) if $validator;
+
     my ($default_key, $keyAliasProps) = &$find_schema_default_key($format);
 
     my $res = '';