mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-15 06:09:47 +00:00
JSONSchema: use validator in print_property_string too
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
parent
70fdc0501b
commit
d500c0381e
@ -1897,9 +1897,12 @@ sub generate_typetext {
|
|||||||
sub print_property_string {
|
sub print_property_string {
|
||||||
my ($data, $format, $skip, $path) = @_;
|
my ($data, $format, $skip, $path) = @_;
|
||||||
|
|
||||||
|
my $validator;
|
||||||
if (ref($format) ne 'HASH') {
|
if (ref($format) ne 'HASH') {
|
||||||
my $schema = get_format($format);
|
my $schema = get_format($format);
|
||||||
die "not a valid format: $format\n" if !$schema;
|
die "not a valid format: $format\n" if !$schema;
|
||||||
|
# named formats can have validators attached
|
||||||
|
$validator = $format_validators->{$format};
|
||||||
$format = $schema;
|
$format = $schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1909,6 +1912,8 @@ sub print_property_string {
|
|||||||
raise "format error", errors => $errors;
|
raise "format error", errors => $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = $validator->($data) if $validator;
|
||||||
|
|
||||||
my ($default_key, $keyAliasProps) = &$find_schema_default_key($format);
|
my ($default_key, $keyAliasProps) = &$find_schema_default_key($format);
|
||||||
|
|
||||||
my $res = '';
|
my $res = '';
|
||||||
|
Loading…
Reference in New Issue
Block a user