package HTML::Widget::Constraint::ISODate;
use warnings;
use strict;
use base 'HTML::Widget::Constraint';
use DateTime::Format::Strptime;
my $format=DateTime::Format::Strptime->new(pattern=>'%F');
sub validate {
my ($self,$value)=@_;
my $ret=eval {
my $val=$format->parse_datetime($value);
return unless defined($val);
my $round_tripped=$val->strftime('%F');
return ($value eq $round_tripped);
};
return if $@;
return $ret;
}
1;