From: Wolfgang Bumiller Date: Thu, 14 Jul 2016 07:21:24 +0000 (+0200) Subject: allow Regexp objects for strings in the schema X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=88a490ff71d5491b2564f4f49931e71410bed9c3;ds=sidebyside allow Regexp objects for strings in the schema The 'pattern' property has type string and format regex, so it makes sense to allow Regexp objects to be used for it. While check_type() doesn't know the format, Regexp objects can be treated like strings anyway, including compared via 'eq' or matched via '=~', so we allow strings to generally come from a Regexp object. --- diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index 5b5fe15..b53736e 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -645,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");