Write validation helpers 

sub valid_input {
    my($name) = @_;
    my $data = params();
    my $results = DemoApp::Validator::check($data, $name);
    my @messages;
    my @invalid_fields;
    if( my @missing = $results->missing ) {
        push @invalid_fields, @missing;
        my $s = @missing == 1 ? '' : 's';
        push @messages, "Missing field$s: " . join(', ', @missing);
    }
    if( my @invalid = $results->invalid ) {
        push @invalid_fields, @invalid;
        my $s = @invalid == 1 ? '' : 's';
        push @messages, "Invalid field$s: " . join(', ', @invalid);
    }
    if( @messages ) {
        $global{validation_errors} = \@messages;
        $global{invalid_fields}    = \@invalid_fields;
        my $q = params();
        fill_in_form($q);
        return;
    }
    my $args = $results->valid;
}