NAME

Compiled::Params::OO - compiled params object oriented.

VERSION

Version 0.01

SYNOPSIS

use Compiled::Params::OO qw/cpo/;
our $validate;
BEGIN {
	$validate = cpo(
		time => {
			testing => Int
			me => {
				type => Str,
				default => {
					return 'insanity';
				}
			}
		},
		circles => [Str, Int]
	);
}

sub new {
	return bless {}, $_[0];
}

sub time {
	my $self = shift;
	my $params = $validate->time->(
		testing => 16000000,
	);
	return $params->me;
}

sub circles {
	my $self = shift;
	my @params = $validate->circles->('dreaming', 211000000);
	...
}

EXPORT

cpo

This package exports a single sub routine cpo (compiled params object) that is a wrapper around Type::Params compile and compile_named_oo. It accepts a list where the key is the named accessor and the value is the params that will be validated. The value can either be a hash reference to build a Type::Params::compile_name_oo call or an array reference of Type::Tiny Objects that will be passed directly to Type::Params::compile. If passed as a hash reference the value can either be a Type::Tiny object or another hash reference with two keys representing a type and default value.

$validate = cpo(
	time => {
		testing => Int
		me => {
			type => Str,
			default => {
				return 'house of lords';
			}
		}
	},
	circles => [Str, { default => sub { 'lucky buddha' } }, Int]
);

AUTHOR

lnation, <email at lnation.org>

BUGS

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

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Compiled::Params::OO

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020 by lnation.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)