X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FJSONSchema.pm;h=debbbb5904004936e4553217fecc3f363db14a05;hp=a2394f74ede21d9f49105f876f42e3b32bf05d0d;hb=8b6e737a752d90cfaf3ecec2dcbc99ffba5a626d;hpb=971353e8ac4191a6ea7125b4c7240cd6387060bd diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index a2394f7..debbbb5 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -229,7 +229,9 @@ my $ipv4_mask_hash = { '255.255.255.224' => 27, '255.255.255.240' => 28, '255.255.255.248' => 29, - '255.255.255.252' => 30 + '255.255.255.252' => 30, + '255.255.255.254' => 31, + '255.255.255.255' => 32, }; register_format('ipv4mask', \&pve_verify_ipv4mask); @@ -643,6 +645,9 @@ sub check_type { return undef; } return 1; + } elsif ($type eq 'string' && $vt eq 'Regexp') { + # qr// regexes can be used as strings and make sense for format=regex + return 1; } else { if ($vt) { add_error($errors, $path, "type check ('$type') failed - got $vt"); @@ -715,7 +720,7 @@ sub check_object { check_prop($value, $requires, $path, $errors); } elsif (!defined($value->{$requires})) { add_error($errors, $path ? "$path.$requires" : $requires, - "missing property - '$newpath' requiers this property"); + "missing property - '$newpath' requires this property"); } } @@ -1671,12 +1676,14 @@ sub schema_get_type_text { } elsif ($phash->{pattern}) { return $phash->{pattern}; } elsif ($type eq 'integer' || $type eq 'number') { + # NOTE: always access values as number (avoid converion to string) if (defined($phash->{minimum}) && defined($phash->{maximum})) { - return "$type ($phash->{minimum} - $phash->{maximum})"; + return "$type (" . ($phash->{minimum} + 0) . " - " . + ($phash->{maximum} + 0) . ")"; } elsif (defined($phash->{minimum})) { - return "$type ($phash->{minimum} - N)"; + return "$type (" . ($phash->{minimum} + 0) . " - N)"; } elsif (defined($phash->{maximum})) { - return "$type (-N - $phash->{maximum})"; + return "$type (-N - " . ($phash->{maximum} + 0) . ")"; } } elsif ($type eq 'string') { if (my $format = $phash->{format}) {