[html-formfu] Date constraint?

vti viacheslav.t at gmail.com
Mon Mar 24 21:06:57 GMT 2008


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;
}

-- 
vti -- Viacheslav Tikhanovskii



More information about the HTML-FormFu mailing list