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!).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|