| 1 | package HTML::TurboForm::Constraint::Date; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | use Date::Calc qw/check_date/; | ||
| 5 | use base qw(HTML::TurboForm::Constraint); | ||
| 6 | |||
| 7 | sub check{ | ||
| 8 | my ($self)=@_; | ||
| 9 | my $result=0; | ||
| 10 | |||
| 11 | my $day=''; | ||
| 12 | my $month=''; | ||
| 13 | my $year=''; | ||
| 14 | my $request=$self->request; | ||
| 15 | |||
| 16 | $day=$request->{$self->{name}.'_day'};# if (exists($request->{$self->{name}.'_day'})); | ||
| 17 | $month=$request->{$self->{name}.'_month'};# if (exists($request->{$self->{name}.'_month'})); | ||
| 18 | $year=$request->{$self->{name}.'_year'};# if (exists($request->{$self->{name}.'year'})) ; | ||
| 19 | |||
| 20 | return 1 if( check_date( $year,$month,$day ) ); | ||
| 21 | return 0; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub message{ | ||
| 25 | my ($self)=@_; | ||
| 26 | return $self->{text}; | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |