GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOJOLICIOUS::VALIDATOR (3)

.ds Aq ’

NAME

Mojolicious::Validator - Validate values

CONTENTS

SYNOPSIS



  use Mojolicious::Validator;

  my $validator  = Mojolicious::Validator->new;
  my $validation = $validator->validation;
  $validation->input({foo => bar});
  $validation->required(foo)->like(qr/ar$/);
  say $validation->param(foo);



DESCRIPTION

Mojolicious::Validator validates values for Mojolicious.

CHECKS

These validation checks are available by default.

    equal_to



  $validation = $validation->equal_to(foo);



String value needs to be equal to the value of another field.

    in



  $validation = $validation->in(foo, bar, baz);



String value needs to match one of the values in the list.

    like



  $validation = $validation->like(qr/^[A-Z]/);



String value needs to match the regular expression.

    size



  $validation = $validation->size(2, 5);



String value length or size of Mojo::Upload object in bytes needs to be between these two values.

    upload



  $validation = $validation->upload;



Value needs to be a Mojo::Upload object, representing a file upload.

FILTERS

These filters are available by default.

    trim



  $validation = $validation->optional(foo, trim);



Trim whitespace characters from both ends of string value with trim in Mojo::Util.

ATTRIBUTES

Mojolicious::Validator implements the following attributes.

    checks



  my $checks = $validator->checks;
  $validator = $validator->checks({size => sub {...}});



Registered validation checks, by default only equal_to, in, like, size and upload are already defined.

METHODS

Mojolicious::Validator inherits all methods from Mojo::Base and implements the following new ones.

    add_check



  $validator = $validator->add_check(size => sub {...});



Register a validation check.



  $validator->add_check(foo => sub {
    my ($validation, $name, $value, @args) = @_;
    ...
    return undef;
  });



    add_filter



  $validator = $validator->add_filter(trim => sub {...});



Register a new filter.



  $validator->add_filter(foo => sub {
    my ($validation, $name, $value) = @_;
    ...
    return $value;
  });



    validation



  my $validation = $validator->validation;



Build Mojolicious::Validator::Validation object to perform validations.



  my $validation = $validator->validation;
  $validation->input({foo => bar});
  $validation->required(foo)->size(1, 5);
  say $validation->param(foo);



SEE ALSO

Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOJOLICIOUS::VALIDATOR (3) 2016-03-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.