[pve-devel] applied: [PATCH v3 common 2/3] JSONSchema: use validator in print_property_string too
Fabian Grünbichler
f.gruenbichler at proxmox.com
Mon Jul 6 11:38:10 CEST 2020
On June 25, 2020 1:35 pm, Stefan Reiter wrote:
> Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
> Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
> ---
> src/PVE/JSONSchema.pm | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
> index f987006..59a2b5a 100644
> --- a/src/PVE/JSONSchema.pm
> +++ b/src/PVE/JSONSchema.pm
> @@ -1878,9 +1878,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;
> }
>
> @@ -1890,6 +1893,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 = '';
> --
> 2.20.1
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
More information about the pve-devel
mailing list