<div class="gmail_quote">2009/3/27 Rodrigo <span dir="ltr">&lt;<a href="mailto:rodrigolive@gmail.com">rodrigolive@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div>  <br></div><div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">But I can&#39;t instatiate<br>
the object because it throws an exception because age is not valid, isn&#39;t it?</blockquote><div> <br></div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">

<br>
Or does Moose check constraints only on provided attributes. This can&#39;t be true<br>
with &quot;required&quot; attributes, can it?<br>
<div></div></blockquote></div><div><br>As long as the attribute is not &quot;required =&gt; 1&quot;, no exception is thrown. </div></div></blockquote><div><br></div><div>I think you are missing his point.  He wants to instantiate an object from the form, but if he uses his Moose object then the things he wants to validate (errors) will prevent him from getting an instance of his class.  If &quot;name&quot; is required or isa &#39;Str&#39; then if it gets an arrayref, he can&#39;t use the object (as either it missing or being the wrong type throws an exception).</div>
<div><br></div><div>I don&#39;t know if this is a good idea yet, but it&#39;s fairly easy to create a &quot;proxy&quot; object for a given class, less all the validation:</div><div><br></div><div><a href="http://www.pastie.org/429140">http://www.pastie.org/429140</a><br>
</div><div><br></div><div>YMMV, but it would do what you want, as you could &quot;promote&quot; it to a real value iteratively after validation...</div></div><br>-- <br>Cory &#39;G&#39; Watson<br><a href="http://www.onemogin.com">http://www.onemogin.com</a><br>