[html-formfu] Date constraint?

Zbigniew Lukasiak zzbbyy at gmail.com
Tue Mar 25 20:15:41 GMT 2008


On Mon, Mar 24, 2008 at 10:06 PM, vti <viacheslav.t at gmail.com> wrote:
> Maybe it should be a standart constraint? I think everybody needs it as long as
>  we have Date element...
>
>  sub constrain_value {
>     my ( $s, $value ) = @_;
>
>     if ( defined $value ) {
>         my $builder = DateTime::Format::Builder->new;
>         $builder->parser( { strptime => $s->parent->strftime } );
>
>         my $dt = $builder->parse_datetime( $value );
>
>         return $dt ? 1 : 0;
>     }
>
>     return 1;
>  }
>

If you use deflate then the text is parsed by DateTime anyway - and if
that fails then you get the error - that's probably why no one wrote
it as a constraint.


>  --
>  vti -- Viacheslav Tikhanovskii
>
>  _______________________________________________
>  HTML-FormFu mailing list
>  HTML-FormFu at lists.rawmode.org
>  http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>



-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/



More information about the HTML-FormFu mailing list