mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-15 12:01:50 +00:00
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.
This commit is contained in:
parent
123921731a
commit
88a490ff71
@ -645,6 +645,9 @@ sub check_type {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
return 1;
|
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 {
|
} else {
|
||||||
if ($vt) {
|
if ($vt) {
|
||||||
add_error($errors, $path, "type check ('$type') failed - got $vt");
|
add_error($errors, $path, "type check ('$type') failed - got $vt");
|
||||||
|
Loading…
Reference in New Issue
Block a user