HOW IT WORKS

Params::Validate::Dependencies extends Params::Validate's validate() function to support an arbitrary number of callbacks which are not associated with any one parameter. All of those callbacks are run after Params::Validate's normal validate() function. If any of them return false, then validate() will die as normal.

SUBROUTINES and EXPORTS

All of the *_of functions are exported by default in addition to those exported by default by Params::Validate. They are also available with the tag ':_of' in case you want to use them without Params::Validate. In that case you would load the module thus:

use Params::Validate::Dependencies qw(:_of);

All of the *_of functions take a list of scalars and code-refs and return a code-ref (which is a closure over the list originally passed to the function) suitable for use in validate() or in another *_of function. All code-refs should take as their only argument a hashref of parameters to check, returning true if the parameters are good and false otherwise.

document

This takes a code-ref argument as generated by a tree of *_of calls, and spits out some documentation of it. This function is not exported.

validate

Overrides and extends Params::Validate's function of the same name.

exclusively

Takes a single subref as its only argument (this would normally be the results of one of the *_of functions), and returns a code-ref which returns true if the hashref it is given only contains fields mentioned in the original function or any of its children. For example ...

because sheep aren't mentioned in the 'any_of' and 'all_of's. Internally this uses the auto-documenter interface to interrogate the child sub. This means that if you want to use exclusively() with third-party extensions then they must support auto-documentation.

This function is not exported by default but can be.

none_of

Returns a code-ref which checks that the hashref it receives matches none of the options given.

You might want to use it thus:

all_of(
'alpha',
none_of(qw(bar baz))
)

to validate that 'alpha' must *not* be accompanied by 'bar' or 'baz'.

one_of

Returns a code-ref which checks that the hashref it receives matches only one of the options given.

any_of

Returns a code-ref which checks that the hashref it receives matches one or more of the options given.

all_of

Returns a code-ref which checks that the hashref it receives matches all of the options given.

Any incompatibility with Params::Validate will be considered to be a bug, with the exception of minor differences in error messages.

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.

SEE ALSO

SOURCE CODE REPOSITORY

COPYRIGHT and LICENCE

Copyright 2016 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.

CONSPIRACY

This module is also free-as-in-mason.

Module Install Instructions

To install Params::Validate::Dependencies, simply copy and paste either of the commands in to your terminal