in reply to Do I need to do escaping in my regex check?
Yes, the parens are being treated as regexp metacharacters. You can escape it outside the pattern using quotemeta($value), or within the pattern using \Q...\E:
if (! (grep /^\Q$value\E$/, @$enum_values)) {However I'd normally rather do this as a hash lookup - faster, and it's already an equality check:
my %enum_values = map +($_ => 1), @{ $constraints->{enum} }; if (keys(%enum_values) && !$enum_values{$value}) { my $enum_values_string = join ', ', sort keys %enum_values; ...
Another option is using the List::Util function 'none' (or 'any' for the inverse):
use List::Util qw{ none }; if (none { $_ eq $value } @$enum_values) { ...
|
|---|