<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;">
<br><div class="gmail_quote"><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"><div class="gmail_quote"><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></blockquote></div><div><br>Well, if the object gets an arrayref when it was expecting an Str then he can&#39;t use the object and it should throw an exception.<br></div></div></blockquote></div><div><br></div><div>
Picking this one to respond to, since Scott said the same thing.</div><div><br></div><div>I think the OPs point was to it&#39;s really easy to go from request params to a constructed object.  He seems to think this a great Way To Do Things™.  His problem was that you can&#39;t do that if the object throws an exception when he tries to instantiate it.  This short-circuits his intent to use the type constraints in Moose implicitly through the constructor.</div>
<div><br></div><div>The replies all point to the idea of mating the params to their attributes and checking the constraints before instantiating.  These are all great, but they don&#39;t solve his problem of using the object back on the form, think:</div>
<div><br></div><div>&lt;input type=&quot;text&quot; value=&quot;[% obj.attribute %]&quot;...&gt;</div><br>As for the OPs stated question: There&#39;s no one true way.  There&#39;s a bunch of opinions. :)<br><div><br></div>
<div>-- <br>Cory &#39;G&#39; Watson<br><a href="http://www.onemogin.com">http://www.onemogin.com</a><br>
</div>