[Catalyst] General Web- and OO-question

Cory Watson jheephat at gmail.com
Fri Mar 27 18:10:48 GMT 2009


2009/3/27 Rodrigo <rodrigolive at 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 =3D> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090327/5ca69=
06c/attachment.htm


More information about the Catalyst mailing list