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

    Params::Validate 1.06

    Download button

    No screenshots available
    Downloads: 516  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Dave Rolsky and Ilya Martynov | More programs
    Perl Artistic License / FREE
    April 7th, 2012, 05:15 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Params::Validate description

    A Perl module to validate method/function parameters.

    Params::Validate is a Perl module to validate method/function parameters.

    SYNOPSIS

    use Params::Validate qw(:all);

    # takes named params (hash or hashref)
    sub foo
    {
    validate( @_, { foo => 1, # mandatory
    bar => 0, # optional
    }
    );
    }

    # takes positional params
    sub bar
    {
    # first two are mandatory, third is optional
    validate_pos( @_, 1, 1, 0 );
    }


    sub foo2
    {
    validate( @_,
    { foo =>
    # specify a type
    { type => ARRAYREF },

    bar =>
    # specify an interface
    { can => [ 'print', 'flush', 'frobnicate' ] },

    baz =>
    { type => SCALAR, # a scalar ...
    # ... that is a plain integer ...
    regex => qr/^d+$/,
    callbacks =>
    { # ... and smaller than 90
    'less than 90' => sub { shift() < 90 },
    },
    }
    }
    );
    }

    sub with_defaults
    {
    my %p = validate( @_, { foo => 1, # required
    # $p{bar} will be 99 if bar is not
    # given. bar is now optional.
    bar => { default => 99 } } );
    }

    sub pos_with_defaults
    {
    my @p = validate_pos( @_, 1, { default => 99 } );
    }

    sub sets_options_on_call
    {
    my %p = validate_with
    ( params => @_,
    spec => { foo => { type SCALAR, default => 2 } },
    normalize_keys => sub { $_[0] =~ s/^-//; lc $_[0] },
    );
    }

    The Params::Validate module allows you to validate method or function call parameters to an arbitrary level of specificity. At the simplest level, it is capable of validating the required parameters were given and that no unspecified additional parameters were passed in.

    It is also capable of determining that a parameter is of a specific type, that it is an object of a certain class hierarchy, that it possesses certain methods, or applying validation callbacks to arguments.


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    validate method | function parameters | Perl module | Params::Validate | validate | method

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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