Simo::Constrain - Constrain functions for Simo;
Version 0.0201
Simo::Constrain is experimental stage. some function will be change.
This class provede many functions intended to use with constrain option. package Book; use Simo; use Simo::Constrain qw( is_str isa is_int ); sub title{ ac constrain => sub{ is_str } }; sub author{ ac constrain => sub{ isa 'Person' } } sub price{ ac constrain => sub{ is_int } }
No function is exported.
All function can be exported.
use Simo::Constrain qw( isa is_object is_int is_str );
The following is constrain functions.
If function return false, error message is set to $@.
If first argument is omitted, all functions receive $_ as first argument.
If it is undef, return true.
If it is defined, return true.
If it is boolean, return true.
( undef, "", 0, and 1 ) are boolean.
If it is value, return true.
Not reference value is value.
If it is string, return true.
Not reference value is string. This is same as value.
If it is number, return true.
If Scalar::Util::looks_like_number return true, it is number.
If it is integer, return true.
If regexp /^-?[0-9]+$/ is matched. it is integer.
If it is reference, return true.
If it is scalar reference, return true.
If it is array reference, return true.
If it is hash reference, return true.
If it is code reference, return true.
If it is regular expression reference, return true.
If it is glob reference, return true.
If it is file handle, return true.
If Scalar::Util::openhandle is true, it is file handle.
If it is objcet, return true.
Blessed value is object, except qr//.
If it is class name, return true.
If /^(\w+::)*\w+$/ is matched, it is class name.
If it is blessed, return true.
If it inherit a Class, return true.
sub author{ ac constrain => sub{ isa 'Person' }, }
Yuki Kimoto, <kimoto.yuki at gmail.com>
<kimoto.yuki at gmail.com>
Please report any bugs or feature requests to bug-simo-constrain at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Simo-Constrain. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-simo-constrain at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Simo::Constrain
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Simo-Constrain
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Simo-Constrain
CPAN Ratings
http://cpanratings.perl.org/d/Simo-Constrain
Search CPAN
http://search.cpan.org/dist/Simo-Constrain/
I study from Moose::Util::TypeConstraints and Most of Simo::Constrain functions is compatible of Moose::Util::TypeConstraints
Moose,Moose::Util::TypeConstraints
Scalar::Util is used in Simo::Constrain
Scalar::Util
Copyright 2009 Yuki, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Simo::Constrain, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Simo::Constrain
CPAN shell
perl -MCPAN -e shell install Simo::Constrain
For more information on module installation, please visit the detailed CPAN module installation guide.