Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    CGI::Ex::Validate 2.32

    Download button

    No screenshots available
    Downloads: 476  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.5/5)
    2 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Paul Seamons | More programs
    Perl Artistic License / FREE
    March 6th, 2008, 00:48 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    CGI::Ex::Validate description

    The "Just Right" form validator with javascript in parallel

    CGI::Ex::Validate is the "Just Right" form validator with javascript in parallel.

    SYNOPSIS

    use CGI::Ex::Validate;

    ### THE SHORT

    my $errobj = CGI::Ex::Validate->new->validate($form, $val_hash);

    ### THE LONG

    my $form = CGI->new;
    # OR #
    my $form = CGI::Ex->new; # OR CGI::Ex->get_form;
    # OR #
    my $form = {key1 => 'val1', key2 => 'val2'};


    ### simplest
    my $val_hash = {
    username => {
    required => 1,
    max_len => 30,
    field => 'username',
    # field is optional in this case - will use key name
    },
    email => {
    required => 1,
    max_len => 100,
    type => 'email',
    },
    email2 => {
    equals => 'email',
    },
    };

    ### ordered (only onevent submit needs order)
    my $val_hash = {
    'group order' => [qw(username email email2)],
    username => {required => 1, max_len => 30},
    email => ...,
    email2 => ...,
    };

    ### ordered again
    my $val_hash = {
    'group fields' => [{
    field => 'username', # field is not optional in this case
    required => 1,
    max_len => 30,
    }, {
    field => 'email',
    required => 1,
    max_len => 100,
    }, {
    field => 'email2',
    equals => 'email',
    }],
    };


    my $vob = CGI::Ex::Validate->new;
    my $errobj = $vob->validate($form, $val_hash);

    # OR #
    # import config using any type CGI::Ex::Conf supports
    my $errobj = $vob->validate($form, "/somefile/somewhere.val");

    if ($errobj) {
    my $error_heading = $errobj->as_string; # OR "$errobj";
    my $error_list = $errobj->as_array; # ordered list of what when wrong
    my $error_hash = $errobj->as_hash; # hash of arrayrefs of errors
    } else {
    # the form passed validation
    }

    ### will add an error for any form key not found in $val_hash
    my $vob = CGI::Ex::Validate->new({no_extra_keys => 1});
    my $errobj = $vob->validate($form, $val_hash);


    my $js_uri_path = '/js/'; # static or dynamic URI path to find CGI/Ex/validate.js
    my $form_name = "the_form"; # name of the form to attach javascript to
    my $javascript = $vob->generate_js($val_hash, $form_name, $js_uri_path);


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    form validator | CGI forms | Perl module | CGI | form | validator

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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