On Fri, Jun 18, 2010 at 09:41:40PM +0100, Pedro Melo wrote:
> Hi,
> 
> On Fri, Jun 18, 2010 at 8:35 PM, Jesse Luehrs <d...@tozt.net> wrote:
> > On Fri, Jun 18, 2010 at 08:14:28PM +0100, Pedro Melo wrote:
> >> On Fri, Jun 18, 2010 at 7:44 PM, Evan Carroll <e...@dealermade.com> wrote:
> >> > Actually you can do this with MX::Types too:
> >> >
> >> > use MooseX::Types -declare => [qw( MyDate DateTime )];
> >> > use MooseX::Types::Moose qw( Str Int HashRef Object );
> >> > use DateTime;
> >> >
> >> > class_type DateTime, { class => 'DateTime' };
> >> >
> >> > subtype MyDate, as DateTime, where { ! $_->hour };
> >>
> >> hmms... I had code like that in a previous version but could not get
> >> it to work. The difference is that you added ", where { ! $_->hour }"
> >> and I had only "subtype MyDate, as DateTime;".
> >>
> >> In fact if I remove the "where..." from you working example, the tests
> >> start failing like mine did. I would like to understand why it needs
> >> the where to work. Back to the docs for me.
> >
> > Coercions aren't run if the input value is already of the correct type.
> 
> I though of that and thats why my original code used MyDate as a
> subtype of Object, not DateTime. In that case it should run, correct?

No, a DateTime object will pass the Object type constraint.

-doy

Reply via email to