You can specify callback for the parameter and check it there:
my $schema = {
section => {
type => 'nested',
child => {
key => {
type => 'string',
callback => sub { die 'Should be a scalar' if ref $_[1
+] eq 'ARRAY' },
},
},
},
};
Also you can add your own type if you want to check multiple parameters.
Update: and here's the example:
use warnings;
use strict;
use 5.010;
use Data::Dumper;
use Config::General;
use Config::Validate qw(mkpath);
my $schema = {
section => {
type => 'nested',
child => { key => { type => 'MyString', }, },
},
};
my $cfgfile = <<'EOF';
<section>
key Foo
key Bar
</section>
EOF
my $config = Config::General->new( -String => $cfgfile );
print Dumper { $config->getall }; ## you can see the array that Con
+fig::General creates
my $validate = Config::Validate->new( schema => $schema );
$validate->add_type( name => 'MyString', validate => \&is_string );
$validate->validate( config => $config );
say "Still alive!";
sub is_string {
return unless ref $_[1];
die "Parameter " . mkpath( $_[3] ) . " should be a scalar!";
}