Acme-CPANModulesBundle-Import-PerlDancerAdvent-2018

 view release on metacpan or  search on metacpan

devdata/http_advent.perldancer.org_2018_22  view on Meta::CPAN

<p>For example:</p>
<pre class="prettyprint">use Dancer2;
get '/:id' =&gt; sub {
    my $id = route_parameters-&gt;{'id'};
    if ( $id !~ /^[0-9]+$/ ) {
        send_error 'Bad ID' =&gt; 400;
    }

    # optional
    my $action = query_parameters-&gt;{'action'};
    unless ( defined $action &amp;&amp; length $action ) {
        send_error 'Bad Action' =&gt; 400;
    }

    # use $id and maybe $action
};</pre>

<p>The more parameters we have, the more annoying it is to write these
tests.</p>
<p>But what's more revealing here is that this validation code is not
actually part of our web code. It's input validation <i>for</i> our web



( run in 0.690 second using v1.01-cache-2.11-cpan-65fba6d93b7 )