Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
My common Mojo stuff
Perl
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
t
README.md

README.md

Validator

my $validator = MojoX::Validator->new;

# Fields
$validator->field([qw/firstname lastname/])->required(1)->length(3, 20);
$validator->field('phone')->required(1)->regexp(qr/^\d+$/);

# Groups
$validator->field([qw/password confirm_password/])->required(1);
$validator->group('passwords' => [qw/password confirm_password/])->equal;

# Conditions
$validator->field('document');
$validator->field('number');
$validator->when('document')->regexp(qr/^1$/)
  ->then(sub { shift->field('number')->required });

$validator->validate($values_hashref);
my $errors_hashref = $validator->errors;
my $validated_values_hashref = $validator->values;

Bot protection

$self->plugin('bot_protection');

Features

  • Dummy field (bot fills out all the fields, including not visible one)
  • Honeypot form (bot submits non visible to a normal user form)
  • Cookies support check (bot has no cookies support)
  • Referrer check (bot submits form with invalid referrer header)
  • Identical fields check (bot submits form with identical fields)
  • Form signature (bot submits without visiting the form page or does it too fast)
  • Flood protection (bot submits forms too fast)
  • DDoS protection (bot submits the same forms many times)
Something went wrong with that request. Please try again.