Added receipt datetime string submission validation & validator test
This commit is contained in:
parent
65d5bab444
commit
d078a09ccd
3 changed files with 16 additions and 3 deletions
|
@ -99,8 +99,8 @@ sub post_upload {
|
|||
$validation->required('transaction_value')->number->gt_num(0);
|
||||
$validation->required('transaction_type')->in( 1, 2, 3 );
|
||||
|
||||
#Check a purchase time was submitted
|
||||
$validation->required('purchase_time');
|
||||
#Check a proper purchase time was submitted
|
||||
$validation->required('purchase_time')->is_full_iso_datetime;
|
||||
|
||||
# First pass of required items
|
||||
return $c->api_validation_error if $validation->has_error;
|
||||
|
|
|
@ -58,6 +58,12 @@ sub register {
|
|||
$value = $app->datetime_formatter->parse_datetime( $value );
|
||||
return defined $value ? undef : 1;
|
||||
});
|
||||
|
||||
$app->validator->add_check( is_full_iso_datetime => sub {
|
||||
my ( $validation, $name, $value ) = @_;
|
||||
$value = $app->parse_iso_datetime( $value );
|
||||
return defined $value ? undef : 1;
|
||||
});
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Reference in a new issue