my $schema = { section => { type => 'nested', child => { key => { type => 'string', callback => sub { die 'Should be a scalar' if ref $_[1] eq 'ARRAY' }, }, }, }, }; #### 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';
key Foo key Bar
EOF my $config = Config::General->new( -String => $cfgfile ); print Dumper { $config->getall }; ## you can see the array that Config::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!"; }