I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2005-11-21 16:33:28-08 by jdhedden
Object::InsideOut v1.13 - Custom Type Checking
Object::InsideOut v1.13 adds support for custom type checking for initializers (i.e., :InitArgs) and accessors. This allow you to you define your own type checking routines using either named subroutines or anonymous subroutines:
package My::Class; { use Object::InsideOut; sub is_int { my $arg = $_[0]; return (Scalar::Util::looks_like_number($arg) && (int($arg) == $arg)); } my @level :Field('Accessor' => 'level', 'Type' => \&My::Class::is_int); my @comment :Field('Accessor' => 'comment', 'Type' => sub { $_[0] ne '' }); my %init_args :InitArgs = ( 'LEVEL' => { 'Field' => \@level, 'Type' => \&My::Class::is_int, }, 'COMMENT' => { 'Field' => \@comment, 'Type' => sub { $_[0] ne '' } }, ); }
See the POD for further details.
Direct Responses: Write a response