[Melbourne-pm] Moose 'isa' property prevents setting attribute to undef

Ian Macdonald ickphum at gmail.com
Sun Sep 16 19:52:37 PDT 2012


We've got a Moose class with this attribute:

has 'dataset' => (
    is => 'rw',
    isa => 'AG::Dataset',
    required => 0,

It's not required so you can happily create objects without supplying a
value for it, but once you've done so, you can't then remove/clear it via
"$object->dataset(undef)" :

    Attribute (dataset) does not pass the type constraint because:
Validation failed for 'AG::Dataset' failed with value undef (not isa

Given that it's legal to have undefs in there initially it seems funny not
to be allowed to revert to that state. Am I missing another property which
will allow this? I'd rather not have to remove the validation or do it
manually, seems like a backward step.

Ian Macdonald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20120917/747e3756/attachment.html>

More information about the Melbourne-pm mailing list