Refactored entire api auth code, and upload endpoint
This commit is contained in:
parent
9974e6f07e
commit
94583f61bf
8 changed files with 283 additions and 351 deletions
|
@ -3,6 +3,7 @@ use Mojo::Base 'Mojolicious::Plugin';
|
|||
|
||||
use Email::Valid;
|
||||
use Geo::UK::Postcode;
|
||||
use Scalar::Util qw/ looks_like_number /;
|
||||
|
||||
sub register {
|
||||
my ( $plugin, $app, $conf ) = @_;
|
||||
|
@ -26,6 +27,16 @@ sub register {
|
|||
my ( $validation, $name, $value ) = @_;
|
||||
return Geo::UK::Postcode->new( $value )->valid ? undef : 1;
|
||||
});
|
||||
|
||||
$app->validator->add_check( number => sub {
|
||||
my ( $validation, $name, $value ) = @_;
|
||||
return looks_like_number( $value ) ? undef : 1;
|
||||
});
|
||||
|
||||
$app->validator->add_check( gt_num => sub {
|
||||
my ( $validation, $name, $value, $check ) = @_;
|
||||
return $value > $check ? undef : 1;
|
||||
});
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Reference in a new issue