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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.