Softpedia
 


LINUX CATEGORIES:



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

    CGI::Validate 2.000

    Download button

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

    License / Price:

    Last Updated:

    Category:
    Byron Brummer | More programs
    Perl Artistic License / FREE
    October 7th, 2006, 06:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    CGI::Validate description

    An advanced CGI form parser and type validation

    CGI::Validate is an advanced CGI form parser and type validation.

    SYNOPSIS

    use CGI::Validate; # GetFormData() only
    use CGI::Validate qw(:standard); # Normal use
    use CGI::Validate qw(:subs); # Just functions
    use CGI::Validate qw(:vars); # Just exception vars

    ## If you don't want it to check that every requested
    ## element arrived you can use this. But I don't recommend it
    ## for most users.
    $CGI::Validate::Complete = 0;

    ## If you don't care that some fields in the form don't
    ## actually match what you asked for. -I don't recommend
    ## this unless you REALLY know what you're doing because this
    ## normally meens you've got typo's in your HTML and we can't
    ## catch them if you set this.
    ## $CGI::Validate::IgnoreNonMatchingFields = 1;

    my $FieldOne = 'Default String';
    my $FieldTwo = 8;
    my $FieldThree = 'some default string';
    my @FieldFour = (); ## For multi-select field
    my @FieldFive = (); ## Ditto
    my $EmailAddress= '';

    ## Try...
    my $Query = GetFormData (
    'FieldOne=s' => $FieldOne, ## Required string
    'FieldTwo=i' => $FieldTwo, ## Required int
    'FieldThree' => $FieldThree, ## Auto converted to the ":s" type
    'FieldFour=s' => @FieldFour, ## Multi-select field of strings
    'FieldFive=f' => @FieldFive, ## Multi-select field of floats
    'Email=e' => $EmailAddress, ## Must 'look' like an email address
    ) or do {
    ## Catch... (wouldn't you just love a case statement here?)
    if (%Missing) {
    die "Missing form elements: " . join (' ', keys %Missing);
    } elsif (%Invalid) {
    die "Invalid form elements: " . join (' ', keys %Invalid);
    } elsif (%Blank) {
    die "Blank form elements: " . join (' ', keys %Blank);
    } elsif (%InvalidType) {
    die "Invalid data types for fields: " . join (' ', keys %InvalidType);
    } else {
    die "GetFormData() exception: $CGI::Validate::Error";
    }
    };

    ## If you only want to check the form data, but don't want to
    ## have CGI::Validate set anything use this. -You still have full
    ## access to the data via the normal B object that is returned.

    use CGI::Validate qw(CheckFormData); # not exported by default
    my $Query = CheckFormData (
    'FieldOne=s', 'FieldTwo=i', 'FieldThree', 'FieldFour',
    'FieldFive', 'Email',
    ) or do {
    ... Same exceptions available as GetFormData above ...
    };

    ## Need some of your own validation code to be used? Here is how you do it.
    addExtensions (
    myType => sub { $_[0] =~ /test/ },
    fooBar => &fooBar,
    i_modify_the_actual_data => sub {
    if ($_[0] =~ /test/) { ## data validation
    $_[0] = 'whatever'; ## modify the data by alias
    return 1;
    } else {
    return 0;
    }
    },
    );
    my $Query = GetFormData (
    'foo=xmyType' => $foo,
    'bar=xfooBar' => $bar,
    'cat=xi_modify_the_actual_data' => $cat,
    );



    ## Builtin data type checks available are:
    s string # Any non-zero length value
    w word # Must have at least one w char
    i integer # Integer value
    f float # Float value
    e email # Must match m/^s*

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    CGI form parser | type validation | Perl module | Validate | CGI | form

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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