simple form validation in dancer/perl
- by devnull
I am trying to do a simple form validation in perl dancer but I was wondering what would be the best way to validate simple parameters (e.g. field cannot be empty, validity of the email, minimum length of a field) in dancer/perl without any extra plugin or CPAN module
here is the code so far
post '/register' => sub {
my $db = connect_db();
my $sql = 'insert into users (username, email, password, motivation) values (?, ?, ? ,?)';
my $sth = $db->prepare($sql) or die $db->errstr;
$sth->execute(params->{'username'}, params->{'email'},params->{'password'}, params->{'motivation'}) or die $sth->errstr;
set_flash('Hey you signed up !');
redirect '/thanks';
};
I did google it and I found several ways to do validation using CPAN modules like Form::Foo but how do it without that ?