Isn't that simply:
my $safe_span = ...; # Whatever you need
my dt = DateTime->new(...);
croak "Bad date range" if $safe_span->contains($dt);
In fact you may want the span to be a spanset to accomodate more fine
grained controls. Is this useful enough to merit a class? I dunno.
As a minor note, it might be nice to be able to chain the Wrappers,
but I have no idea what syntax one would use.
-ben
On Sun, Jun 15, 2003 at 04:15:49PM -1000, Joshua Hoblitt wrote:
[snip]
>
> However - I was thinking of a validator that could be configured with input ranges
> for each parameter.
>
> Example:
>
> $start = DateTime->new( year => 1939 );
> $end = DateTime->new( year => 1945 );
> $year_span = DateTime::Span->from_datetimes( start => $start, end => $end );
>
> my $dtvdator = DateTime::Wrapper::Validator->watch( year => $year_span );
>
> # creates a DT object
> my $dt = $dtvdator->new( year => 1944 );
>
> # throws an exception
> my $dt = $dtvdator->new( year => 1938 );
>
> I'm kinda fuzzy on watch the syntax (or what the method name should be).
>
> -J
>
> --
>