NAME

Mojolicious::Plugin::AdditionalValidationChecks

VERSION

version 0.01

SYNOPSIS

# Mojolicious
$self->plugin('AdditionalValidationChecks');

# Controller
my $validation = $self->validation;
$validation->input({ nr => 3 });
$validation->required( 'nr' )->max( 10 );

DESCRIPTION

Mojolicious::Plugin::AdditionalValidationChecks adds a few validation checks to the Mojolicious validator.

NAME

Mojolicious::Plugin::AdditionalValidationChecks - Mojolicious Plugin

CHECKS

These checks are added:

email

Checks that the given value is a valid email. It uses Email::Valid.

simple check

This does only check whether the given mailaddress is valid or not

my $validation = $self->validation;
$validation->input({ email_address => 'dummy@test.example' });
$validation->required( 'email_address' )->email();

check also MX

Check if there's a mail host for it

my $validation = $self->validation;
$validation->input({ email_address => 'dummy@test.example' });
$validation->required( 'email_address' )->email(-mxcheck => 1);

phone

*not implemented yet*

min

Checks a number for a minimum value. If a non-number is passed, it's always invalid

my $validation = $self->validation;
$validation->input({ nr => 3 });
$validation->required( 'nr' )->min( 10 ); # not valid
$validation->required( 'nr' )->min( 2 );  # valid
$validation->input({ nr => 'abc' });
$validation->required( 'nr' )->min( 10 ); # not valid

max

Checks a number for a maximum value. If a non-number is passed, it's always invalid

my $validation = $self->validation;
$validation->input({ nr => 3 });
$validation->required( 'nr' )->max( 10 ); # not valid
$validation->required( 'nr' )->max( 2 );  # valid
$validation->input({ nr => 'abc' });
$validation->required( 'nr' )->max( 10 ); # not valid

length

*not implemented yet*

int

Checks if a number is an integer. If a non-number is passed, it's always invalid

my $validation = $self->validation;
$validation->input({ nr => 3 });
$validation->required( 'nr' )->int(); # valid
$validation->input({ nr => 'abc' });
$validation->required( 'nr' )->int(); # not valid
$validation->input({ nr => '3.0' });
$validation->required( 'nr' )->int(); # not valid

http_url

Checks if a given string is an absolute URL with http or https scheme.

my $validation = $self->validation;
$validation->input({ url => 'http://perl-services.de' });
$validation->required( 'url' )->http_url(); # valid
$validation->input({ url => 'https://metacpan.org' });
$validation->required( 'url' )->http_url(); # valid
$validation->input({ url => 3 });
$validation->required( 'url' )->http_url(); # not valid
$validation->input({ url => 'mailto:dummy@example.com' });
$validation->required( 'url' )->http_url(); # not valid

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.

AUTHOR

Renee Baecker <reneeb@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)