Esteemed monks,
I'm reading a configuration file using Config::General and validating it via Config::Validate. The goal is to reject the configuration and die if there are any errors in it.
One of the requirements I want to impose is that some configuration keys shouldn't be repeated. When I repeat a key, Config::General creates an array to hold all the given values. I expect Config::Validate to reject that array (since it's not a plain string) but that's not happening. Funnily, if I tell Config::Validate that I want an integer instead of a string, it does die as desired.
Here is some code to show the problem:
#!/opt/QNDperl5.10/bin/perl use warnings; use strict; use 5.010; use Data::Dumper; use Config::General; use Config::Validate; my $schema = { section => { type => 'nested', child => { key => { ## change this to see the code die if 'integer' is use +d type => 'string', #type => 'integer', }, }, }, }; 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 Confi +g::General creates Config::Validate->new (schema => $schema)->validate (config => $config +); say "Still alive!";
How do I reject such a configuration?
Update: I just reported this bug.
--
David Serrano
(Please treat my english text just like Perl code, i.e. feel free to notify me of any syntax, grammar, style and/or spelling error. Thank you!).
In reply to Config::Validate: problem with a key type by Hue-Bond
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |