NAME

Params::Validate::Micro - Validate parameters concisely

VERSION

Version 0.01

SYNOPSIS

use Params::Validate::Micro qw(:all);
use Params::Validate::Micro qw(micro_validate micro_translate);

DESCRIPTION

Params::Validate::Micro allows you to concisely represent a list of arguments, their types, and whether or not they are required.

Nothing is exported by default. Use :all or the specific function name you want.

FORMAT

Micro argument strings are made up of lists of parameter names. Each name may have an optional sigil (one of $@%), which translate directly to the Params::Validate constrations of SCALAR, ARRAYREF, and HASHREF, respectively.

There may be one semicolon (;) in your argument string. If present, any parameters listed after the semicolon are marked as optional.

Examples:

Single scalar argument
$text
Hashref and optional scalar
%opt; $verbose
Two arrayrefs and an untyped argument
@addrs @lines message

FUNCTIONS

micro_translate

my %spec = micro_translate($string);

Turns $string into a Params::Validate spec as described in "FORMAT".

This returns a list, which just happens to be a set of key => value pairs. This matters because it means that if you wanted to you could treat it as an array for long enough to figure out what order the parameters were specified in.

In the future, this will probably lead to some kind of dual named / positional validation.

micro_validate

my $arg = micro_validate(\@_, $string, $extra);

First, uses micro_translate on $string, then merges the resultant spec and the optional $extra hashref, and passes the whole thing to Params::Validate.

Returns a hashref of the validated arguments.

AUTHOR

Hans Dieter Pearcey, <hdp@cpan.org>

BUGS

Please report any bugs or feature requests to bug-params-validate-micro@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Params-Validate-Micro. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright 2005 Hans Dieter Pearcey, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.