| Object-Lazy documentation | Contained in the Object-Lazy distribution. |
Object::Lazy::Validate - validator and initializer for Object::Lazy
0.08
use Object::Lazy::Validate;
my ($class, $params) = Object::Lazy::Validate::validate_new(@_);
$params = Object::Lazy::Validate::init($params);
Validator and initializer for Object::Lazy
Validator for the constructor of the package Object::Lazy.
Initializer for the constructor of the package ObjectLazy.
Validator and initializer can confess at false parameters.
nothing
not known
not known
Steffen Winkler
Copyright (c) 2007 - 2010,
Steffen Winkler
<steffenw at cpan.org>.
All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Object-Lazy documentation | Contained in the Object-Lazy distribution. |
package Object::Lazy::Validate; use strict; use warnings; our $VERSION = '0.08'; use Params::Validate qw(:all); sub validate_new { ## no critic (ArgUnpacking) return validate_with( params => \@_, spec => [ {type => SCALAR}, {type => CODEREF | HASHREF}, ], stack_skip => 1, ); } # check and modify params sub init { my $params = shift; if (ref $params eq 'CODE') { $params = { build => $params, }; } return validate_with( params => $params, spec => { build => {type => CODEREF}, isa => {type => SCALAR | ARRAYREF, default => []}, DOES => {type => SCALAR | ARRAYREF, default => []}, VERSION => {type => SCALAR | OBJECT, optional => 1}, version_from => {type => SCALAR, optional => 1}, logger => {type => CODEREF, optional => 1}, ref => { type => SCALAR, optional => 1, callbacks => { 'depends use Object::Lazy::Ref' => sub { $Object::Lazy::Ref::VERSION; } } }, }, called => 'the 2nd parameter hashref', ); }; # $Id$ 1; __END__