In Moose v1.x, I used to be able to do this:
package Class;
use Test::More tests => 1;
use Moose;
use MooseX::Types::Moose qw/Undef Str/;
eval {
has 'trait_boom' => (
is => 'rw'
, isa => Str | Undef
, default => ''
, traits => ['String']
);
};
ok ( !$@, "Created attr trait_boom, a type union of Str and Undef\n$@" );
However, it no longer works with Moose 2.x. I assume this is a bug. Why did Moose break backwards compatibility? Is there another way to get this job done. I want that to be either Undef
or a Str
. I do not want to coerce Undef
to an empty string though.
I'm only asking here because apparently magnet is broke
17:43 [perl2] -!- ERROR Closing Link: 64.200.109.13 (Banned)