Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Catalyst::Controller::Constraints 0.10_02

    Download button

    No screenshots available
    Downloads: 409  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Robert Sedlacek | More programs
    Perl Artistic License / FREE
    July 28th, 2007, 03:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Catalyst::Controller::Constraints description

    Contains Constraint Signatures for Controller Actions.

    Catalyst::Controller::Constraints contains Constraint Signatures for Controller Actions.

    SYNOPSIS

    package MyApp::Controller::Foo;
    ...
    use base qw(Catalyst::Controller::Constraints);

    __PACKAGE__->config(
    constraints => {

    # allow only digits for type 'Integer'
    Integer => qr/^d+$/,

    # allow only word chars for type 'Word'
    Word => sub { /^w+$/ },

    # validate user id and inflate to object
    User => {

    # check the user id
    check => sub {
    my ( $self, $c, $id ) = @_;
    return $c->is_valid_user_id( $id );
    },

    # forward to this action if the validation failed
    on_fail => 'invalid_user',

    # if value is valid, run it through this filter
    # afterwards
    post_filter => sub {
    my ( $self, $c, $id ) = @_;
    $c->fetch_user_by_id( $id );
    },
    }

    # inheritance
    HighInteger => {
    inherit_from => 'Integer',
    check => sub { $_ > 22 },
    },

    # collapse multiple arguments
    MyDate => {

    # take three integers and return one value
    takes => 3,
    gives => 1,

    # inflate to a datetime object
    post_filter => sub {
    my ( $self, $c, $y, $m, $d ) = @_;
    DateTime->new(
    year => $y, month => $m, day => $d );
    }
    }
    }
    );

    # add two integers, just throws exception on constraint failure
    sub add : Local Args(2) Constraints(Integer a, Integer b) {
    my ( $self, $c ) = @_;
    $c->res->body( $_{a} + $_{b} );
    }

    # puts the word into the stash, under the key 'foo'
    sub stashword : Local Args(1) Constraints( Word foo* ) { }

    # user_obj ends as a user object in the stash
    sub view_user : Local Args(1) Constraints( User user_obj* ) { }
    sub invalid_user : Private {
    # handle invalid userid
    }

    1;



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Constraint Signatures | Controller Actions | Perl module | Catalyst | Constraint | Signatures

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM