jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:
I am using Data::FormValidator and Data::FormValidator::Constraints::Dates in my CGI::Application based webapp. I have realised that when I enter an invalid time (I am only validating time) then I get an error page returned BUT the messages that should be output are missing.
Here is the relevant part of the Data::Dumper dump of the results object:
You can clearly see the _CURRENT_CONSTRAINT_VALUE is an invalid time ( 21:65:00 ), it is listed in the 'invalid' hash, but as you can see no 'msgs' have been loaded.'missing' => {}, 'valid' => { 'intstart' => '08:00:00', 'intid' => '29' }, '__CURRENT_CONSTRAINT_NAME' => 'date_and_time', '__CURRENT_CONSTRAINT_VALUE' => '21:65:00', 'msgs' => {}, 'unknown' => { 'rm' => 1, '_save' => 1, 'dow' => 1 }, 'invalid' => { 'intend' => [ 'date_and_time' ] }
The doc's for D::FV::C::Dates does not mention anything about messages. Does any body have an idea of what is happening here? I am still reading doc's!
BTW I am using D::FV 3.14, I am about to upgrade to the latest release which appears to be 3.50.
UPDATED Code added as suggested:
sub edit_bh_process { my $self = shift; my $sess = $self->param('up_session'); my ($results, $err_page) = $self->check_rm('edit_bh_display', { debug => 1, required => [qw/intid/], optional => [qw/intstart intend/], filters => ['trim'], validator_packages => [qw(Data::FormValidator::Constraints::Da +tes)], constraints => { intstart => { name => 'date_and_time', constraint_method => 'date_and_time', params => [ \'hh:mm:ss' ], }, intend => { name => 'date_and_time', constraint_method => 'date_and_time', params => [ \'hh:mm:ss' ], }, }, msgs => { constraints => { 'date_and_time' => "Invalid time format", }, any_errors => 'err__', prefix => 'err_', }, } ); # if errors return the error page #print STDERR $err_page, "\n"; print STDERR Dumper( $results ); return $err_page if $err_page; #Results seem valid! my $dfv_results = $results->valid(); print STDERR Dumper( $dfv_results ); return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Data::FormValidator messages missing?
by Anonymous Monk on Jan 14, 2004 at 22:03 UTC |