Hi Ian,<div>You most likely want to delete the attribute entirely, rather than setting it to undef.</div><div><br></div><div>One way is to define a clearer property for it:</div><div><br></div><div><div>package Foo;</div><div>
<br></div><div>use Moose;</div><div><br></div><div># ...</div><div><br></div><div>has 'dataset' => (</div><div>    is => 'rw',</div><div>    isa => 'AG::Dataset',</div><div>    required => 0,</div>
<div>    clearer => 'clear_dataset',</div><div>);</div></div><div><br></div><div>then ...</div><div><br></div><div><div>my $foo = Foo->new();</div><div>$foo->dataset(bless {}, 'AG::Dataset');</div>
<div><br></div><div>use YAML::Syck; print YAML::Syck::Dump({foo => $foo});</div><div><br></div><div>$foo->clear_dataset;</div><div><br></div><div>use YAML::Syck; print YAML::Syck::Dump({foo => $foo});</div></div>
<div><br></div><div>- David</div><div><br><div class="gmail_quote">On Mon, Sep 17, 2012 at 12:52 PM, Ian Macdonald <span dir="ltr"><<a href="mailto:ickphum@gmail.com" target="_blank">ickphum@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br><br>We've got a Moose class with this attribute:<br><br><br>has 'dataset' => (<br>    is => 'rw',<br>
    isa => 'AG::Dataset',<br>    required => 0,<br>);<br><br clear="all">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)" :<br>

<br>    Attribute (dataset) does not pass the type constraint because: Validation failed for 'AG::Dataset' failed with value undef (not isa AG::Dataset)<br><br>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.<br>

<br>Thanks,<span class="HOEnZb"><font color="#888888"><br>-- <br>Ian Macdonald<br><br>
</font></span><br>_______________________________________________<br>
Melbourne-pm mailing list<br>
<a href="mailto:Melbourne-pm@pm.org">Melbourne-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/listinfo/melbourne-pm</a><br></blockquote></div><br></div>