'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);
# In property strings we default to not allowing additional properties
$additional_properties = 0 if !defined($additional_properties);
+ # Support named formats here, too:
+ if (!ref($format)) {
+ if (my $desc = $format_list->{$format}) {
+ $format = $desc;
+ } else {
+ die "unknown format: $format\n";
+ }
+ } elsif (ref($format) ne 'HASH') {
+ die "unexpected format value of type ".ref($format)."\n";
+ }
+
my $default_key;
my $res = {};
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");
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");
}
}
} elsif ($phash->{format_description}) {
return "<$phash->{format_description}>";
} elsif ($phash->{enum}) {
- return "(" . join(' | ', sort @{$phash->{enum}}) . ")";
+ return "<" . join(' | ', sort @{$phash->{enum}}) . ">";
} 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}) {
}
}
- return $type;
+ return "<$type>";
}
1;