Params::Check::Item - checks the type or value of an item at any point during execution
Version 0.02
Params::Check::Items exports a bunch of utility functions for checking the values of items through Carp::Assert. It is different than other parameter checking modules since it has low configuration overhead and you are expected to check one parameter at a time, instead of creating a giant hash of all the valid values for all the parameters, such as Params::Check. All exported functions optionally take in a message parameter at the end that is displayed if Carp::Assert fails.
If you would like to disable the checks, you must set the environment variable PARAMS_CHECK_ITEM_OFF=1. Note that this can be toggled on and off during runtime.
An example:
use Params::Check::Item; sub myFunc { my ($row, $col, $matrix) = @_[0..2]; checkIndex($row, "row not an index"); checkIndex($col, "col not an index"); checkClass($matrix, "My::Matrix::Type", "invalid matrix"); $matrix->get($row, $col); }
All exported subroutines take in an optional string message, [MSG], to display on failure. Addtionally, the subroutines will not perform the check if the environment variable PARAMS_CHECK_ITEM_OFF is set.
checks that NUM is numeric type
checks that NUM is an integer
checks that NUM is a valid index (e.g., 0,1,2,3...)
checks that OBJECT is a blessed object from class of name CLASSNAME
checks that NUM1 == NUM2
checks that NUM1 != NUM2
checks that NUM1 < NUM2
checks that NUM1 <= NUM2
checks that simple item ITEM is present in the array referenced by ARRAYREF. This simply performs string comparison. It must be an exact match with one of the items in the array to pass.
simply fails and says "Not Implemented: [MSG]". good for stubbing out functions.
Params::Check
Samuel Steffl, sam@ssteffl.com
sam@ssteffl.com
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Params-Check-Item. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Params::Check::Item
Copyright 2017 Samuel Steffl.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Params::Check::Item, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Params::Check::Item
CPAN shell
perl -MCPAN -e shell install Params::Check::Item
For more information on module installation, please visit the detailed CPAN module installation guide.