sub submit_order {
my $self = shift;
require Data::FormValidator;
my $query = $webapp->query;
my $cgi_params = $query->Vars();
###################
my $validation_profile = { required => [ 'drink_brand' ],
optional => [ 'quantity' ],
field_filters => {
quantity => 'digit',
drink_brand => 'trim',
},
};
my $results = Data::FormValidator->check($cgi_params,
$validation_profile);
if ($results->has_invalid or $results->has_missing) {
# Display an error, force a re-submission of the form
}
else {
# Success! Submit the order to bartender
}
} |