|
Found Moose::Util::TypeConstraints via a search, it offers a simple
enum function. The following worked as a one-liner: use Moose::Util::TypeConstraints; enum q{Col}, [qw(red blue green)]; no Moose::Util::TypeConstraints; package bob; use Moose; has qw(color is rw isa Col); package main; my $bob = bob->new(color => q{green}); print $bob->color; # prints "green" $bob->color(q{yellow}); # dies print $bob->color; The error you get when you set an invalid value is something like: Attribute (color) does not pass the type constraint because: Validation failed for 'Col' with value yellow at ... On 04/04/2012 10:08 AM, Dov Levenglick wrote: I believe (after trying) that this won't work. Either I tried this wrong, or else Perl is looking for some module called MyEnum.pmBest Regards, Dov Levenglick On Wed, Apr 4, 2012 at 09:40, Shmuel Fomberg <[email protected]> wrote:
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
