Params::Validate::Dependencies::all_or_none_of
An extension for Params::Validate::Dependencies to validate that either all of or none of a list of params are present.
In this example, the 'foo' function takes named arguments, of which the 'day', 'month', and 'year' args must either all be present or none of them be present.
use Params::Validate::Dependencies qw(:all); use Params::Validate::Dependencies::all_or_none_of; sub foo { validate(@_, { ... normal Params::Validate stuff ...}, all_or_none_of(qw(day month year)) ); }
This is exported by default. It takes a list of scalars and code-refs and returns a code-ref which checks that the hashref it receives matches either all or none of the options given.
Some of the above is incorrect. If you really want to know what's going on, look at Params::Validate::Dependencies::Extending.
I like to know who's using my code. All comments, including constructive criticism, are welcome.
Please report any bugs either by email or using http://rt.cpan.org/ or at https://github.com/DrHyde/perl-modules-Params-Validate-Dependencies/issues.
Bug reports should contain enough detail that I can replicate the problem and write a test. The best bug reports have those details in the form of a .t file. If you also include a patch I will love you for ever.
Params::Validate::Dependencies
Data::Domain::Dependencies
git://github.com/DrHyde/perl-modules-Params-Validate-Dependencies-all_or_none_of.git
https://github.com/DrHyde/perl-modules-Params-Validate-Dependencies-all_or_none_of/
Copyright 2011 David Cantrell <david@cantrell.org.uk>
This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.
This module is also free-as-in-mason.
To install Params::Validate::Dependencies::all_or_none_of, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Params::Validate::Dependencies::all_or_none_of
CPAN shell
perl -MCPAN -e shell install Params::Validate::Dependencies::all_or_none_of
For more information on module installation, please visit the detailed CPAN module installation guide.