Acme-Sub-Parms
view release on metacpan or search on metacpan
lib/Acme/Sub/Parms.pod view on Meta::CPAN
verifying that a specific class was passed.
Note; This B<does not> verify that anything _was_ passed, only that
B<if> something was passed, it posesses the specified object method.
If only one method is being specified, the quote marks around the names
of the method may be omitted.
The 'can' requirements are cumulative - if you specify two or more they
are B<all> required.
Examples:
# Required parameter with a 'param' method
BindParms : (
my $cgi = cgi [required, can=param];
)
# Required parameter with 'param' and 'cookie' methods
BindParms : (
my $cgi = cgi [required, can="param cookie"]
)
=back
=over 4
=item isa=classname | isa="classname1 classname2 classname3 ..."
The 'isa' declaration generates a validation requirement that a passed
value 'isa' reference to a class or a subclass of one or more of the
specified classes.
This can also be used for checking Perl's built-in reference types such
as 'HASH', 'ARRAY' or 'CODE'.
Note: This B<does not> verify that anything _was_ passed, only that
B<if> something was passed, it 'isa' instance or subclass of the
specified type.
Examples:
# Optional 'HASH'
BindParms : (
my $data = thing [optional, isa=HASH];
)
# Required 'Mammal' or 'Bacteria' or 'Virus' object or subclasses
BindParms : (
my $lifeform = organism [required, isa="Mammal Bacteria Virus"];
)
=back
=over 4
=item type=classname | type="type1 type2 type3 ..."
The 'type' declaration generates a validation requirement that a passed
value is an instance of the specified type. This is an B<exact match>
requirement. It does not check for class inheritance or blessed objects.
If you specify a reference type or a class name it must match B<exactly>.
This can also be used for checking Perl's built-in reference types such
as 'HASH', 'ARRAY' or 'CODE'.
Note: This B<does not> verify that anything _was_ passed, only that
B<if> something was passed, it is of the specified type.
Examples:
# Optional 'HASH'
BindParms : (
my $data = thing [optional, type=HASH];
)
# Required 'Mammal' or 'Bacteria' or 'Virus' object
BindParms : (
my $lifeform = organism [type="Mammal Bacteria Virus"];
)
=back
=over 4
=item default=something | default="some thing with spaces"
The 'default' declaration allows the setting of default values for
optional parameters (it is implicit that if omitted the default value
is undef).
If the value contains whitespace (or if you want the empty string
value), you will need to use quotes around it.
'default' behaves differently for required and optional parameters:
For an optional parameter, it only activates if the parameter is
omitted completely. It will not kick in for a value that is passed
but has the undefined value.
For a required parameter, it only activates if the parameter is
undefined.
=back
=over 4
=item callback=function_name
The 'callback' declaration lets you specify a function name to be used
to perform validation on the parameter(s).
The syntax is simple: callback=validation_function_name
There is no support for method style calls, only ordinary function calls.
The callback function is called with three
parameters: ($field_name, $field_value, $arguments_anon_hash)
The $field_name and $field_value arguments are obvious,
the $arguments_anon_hash is a 'live' reference to a hash containing
all of the arguments being processed by BindParms block.
( run in 1.869 second using v1.01-cache-2.11-cpan-5a3173703d6 )