2009/3/27 Rodrigo <rodrigol...@gmail.com>

>
>
>> But I can't instatiate
>> the object because it throws an exception because age is not valid, isn't
>> it?
>
>
>
>>
>> Or does Moose check constraints only on provided attributes. This can't be
>> true
>> with "required" attributes, can it?
>>
>
> As long as the attribute is not "required => 1", no exception is thrown.
>

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 "name" is required or isa 'Str' then if it gets an arrayref, he can't
use the object (as either it missing or being the wrong type throws an
exception).

I don't know if this is a good idea yet, but it's fairly easy to create a
"proxy" object for a given class, less all the validation:

http://www.pastie.org/429140

YMMV, but it would do what you want, as you could "promote" it to a real
value iteratively after validation...

-- 
Cory 'G' Watson
http://www.onemogin.com
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to