From 414acd76fb09ebd033b54a19cc5397dc2c3e1047 Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 18 Sep 2017 11:11:53 +0100 Subject: [PATCH] Transaction API errors improved --- lib/Pear/LocalLoop/Controller/Api/Upload.pm | 25 ++++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/Upload.pm b/lib/Pear/LocalLoop/Controller/Api/Upload.pm index e7ae0d5..0a75f3f 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Upload.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Upload.pm @@ -54,13 +54,13 @@ has error_messages => sub { in => { message => 'transaction_type is not a valid value.', status => 400 }, }, transaction_value => { - required => { message => 'transaction_value is missing', status => 400 }, - number => { message => 'transaction_value does not look like a number', status => 400 }, - gt_num => { message => 'transaction_value cannot be equal to or less than zero', status => 400 }, + required => { message => 'transaction amount is missing', status => 400 }, + number => { message => 'transaction amount does not look like a number', status => 400 }, + gt_num => { message => 'transaction amount cannot be equal to or less than zero', status => 400 }, }, purchase_time => { - required => { message => 'purchase_time is missing', status => 400 }, - is_full_iso_datetime => { message => 'purchase_time is in incorrect format', status => 400 }, + required => { message => 'purchase time is missing', status => 400 }, + is_full_iso_datetime => { message => 'purchase time is in incorrect format', status => 400 }, }, file => { 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 }, }, organisation_id => { - required => { message => 'organisation_id is missing', 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 }, + required => { message => 'existing organisation ID is missing', 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 }, }, 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 => { - required => { message => 'search_name is missing', status => 400 }, + required => { message => 'search name is missing', status => 400 }, }, postcode => { required => { message => 'postcode is missing', status => 400 }, @@ -139,7 +142,7 @@ sub post_upload { # Unknown Organisation $validation->required('organisation_name'); $validation->optional('street_name'); - $validation->optional('town'); + $validation->required('town'); $validation->optional('postcode')->postcode; return $c->api_validation_error if $validation->has_error;