Started working on registration page on website, with validation

This commit is contained in:
Tom Bloor 2017-04-08 18:25:34 +01:00
parent cb9819aa2e
commit 0a32b05b6c
6 changed files with 151 additions and 4 deletions

View file

@ -0,0 +1,19 @@
package Pear::LocalLoop::Plugin::Validators;
use Mojo::Base 'Mojolicious::Plugin';
use Email::Valid;
sub register {
my ( $plugin, $app, $conf ) = @_;
$app->validator->add_check( email => sub {
my ( $validation, $name, $email ) = @_;
return Email::Valid->address( $email ) ? undef : 1;
});
$app->validator->add_check( in_resultset => sub {
my ( $validation, $name, $value, $key, $rs ) = @_;
return $rs->search({ $key => $value })->count ? undef : 1;
});
}
1;