in reply to Moose and enum

Can you show us the code that doesn't fail, because
package Person; use Moose; use Moose::Util::TypeConstraints; enum Gender => qw(female male); has sex => ( is => 'rw', isa => 'Gender' ); package main; my $M = Person->new( sex => '' ); # fails #$M->sex( 'please' ); # fails

both fail for me (Uncaught exception from user code: Attribute (sex) does not pass the type constraint because: Validation failed for 'Gender' failed).

Update:

$ perl -MMoose -E 'say $Moose::VERSION' 0.44 $ perl -MMoose::Util::TypeConstraints -E 'say $Moose::Util::TypeConstr +aints::VERSION' 0.22 $ perl -v This is perl, v5.10.0 built for x86_64-linux-gnu-thread-multi

Unless I state otherwise, all my code runs with strict and warnings

Replies are listed 'Best First'.
Re^2: Moose and enum
by myffy (Acolyte) on May 29, 2008 at 10:18 UTC
    Ok, seems to be something funny going on here.
    my $M = Person->new( name => 'A', sex => 'please' ); print $M->dump;
    produces this output:
    $VAR1 = bless( { 'sex' => 'please' }, 'Person' );
    I guesss it could be a platform/version issue:
    C:\>perl -MMoose -e "print $Moose::VERSION" 0.22 C:\>perl -MMoose::Util::TypeConstraints -e "print $Moose::Util::TypeCo +nstraints::VERSION" 0.13 C:\>perl -v This is perl, v5.8.8 built for MSWin32-x86-multi-thread
      I downloaded Moose version 0.22 from CPAN, but it failed most of its tests.

      I'd try upgrading if I were you


      Unless I state otherwise, all my code runs with strict and warnings