use Data::DynamicValidator qw/validator/; my $data = { ports => [2222] }; my $errors = validator($data)->( on => '/ports/*', should => sub { @_ > 0 }, because => 'At least one port should be defined at "ports" section', )->errors; if(!@$errors){ say "all ok"; } else { say $_->reason for(@$errors); }