Transaction API errors improved

This commit is contained in:
Finn 2017-09-18 11:11:53 +01:00
parent f59cf88b09
commit 414acd76fb

View file

@ -54,13 +54,13 @@ has error_messages => sub {
in => { message => 'transaction_type is not a valid value.', status => 400 }, in => { message => 'transaction_type is not a valid value.', status => 400 },
}, },
transaction_value => { transaction_value => {
required => { message => 'transaction_value is missing', status => 400 }, required => { message => 'transaction amount is missing', status => 400 },
number => { message => 'transaction_value does not look like a number', status => 400 }, number => { message => 'transaction amount does not look like a number', status => 400 },
gt_num => { message => 'transaction_value cannot be equal to or less than zero', status => 400 }, gt_num => { message => 'transaction amount cannot be equal to or less than zero', status => 400 },
}, },
purchase_time => { purchase_time => {
required => { message => 'purchase_time is missing', status => 400 }, required => { message => 'purchase time is missing', status => 400 },
is_full_iso_datetime => { message => 'purchase_time is in incorrect format', status => 400 }, is_full_iso_datetime => { message => 'purchase time is in incorrect format', status => 400 },
}, },
file => { file => {
required => { message => 'No file uploaded', status => 400 }, required => { message => 'No file uploaded', status => 400 },
@ -68,15 +68,18 @@ has error_messages => sub {
filetype => { message => 'File must be of type image/jpeg', status => 400 }, filetype => { message => 'File must be of type image/jpeg', status => 400 },
}, },
organisation_id => { organisation_id => {
required => { message => 'organisation_id is missing', status => 400 }, required => { message => 'existing organisation ID is missing', status => 400 },
number => { message => 'organisation_id is not a number', status => 400 }, number => { message => 'organisation ID is not a number', status => 400 },
in_resultset => { message => 'organisation_id does not exist in the database', status => 400 }, in_resultset => { message => 'organisation ID does not exist in the database', status => 400 },
}, },
organisation_name => { organisation_name => {
required => { message => 'organisation_name is missing', status => 400 }, required => { message => 'organisation name is missing', status => 400 },
},
town => {
required => { message => 'town/city is missing', status => 400 },
}, },
search_name => { search_name => {
required => { message => 'search_name is missing', status => 400 }, required => { message => 'search name is missing', status => 400 },
}, },
postcode => { postcode => {
required => { message => 'postcode is missing', status => 400 }, required => { message => 'postcode is missing', status => 400 },
@ -139,7 +142,7 @@ sub post_upload {
# Unknown Organisation # Unknown Organisation
$validation->required('organisation_name'); $validation->required('organisation_name');
$validation->optional('street_name'); $validation->optional('street_name');
$validation->optional('town'); $validation->required('town');
$validation->optional('postcode')->postcode; $validation->optional('postcode')->postcode;
return $c->api_validation_error if $validation->has_error; return $c->api_validation_error if $validation->has_error;