Skip to content

Commit

Permalink
Changed error message to explicitly name the field causing the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
willdoran committed Jun 27, 2016
1 parent 37cd856 commit df8d2d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions application/classes/Ushahidi/Validator/Post/Create.php
Expand Up @@ -194,7 +194,7 @@ public function checkValues(Validation $validation, $attributes, $data)
if (count($values) > $attribute->cardinality AND $attribute->cardinality != 0)
{
$validation->error('values', 'tooManyValues', [
$key,
$attribute->label,
$attribute->cardinality
]);
}
Expand All @@ -207,11 +207,11 @@ public function checkValues(Validation $validation, $attributes, $data)

if (!is_array($values))
{
$validation->error('values', 'notAnArray', [$key]);
$validation->error('values', 'notAnArray', [$attribute->label]);
}
elseif ($error = $validator->check($values))
{
$validation->error('values', $error, [$key, $values]);
$validation->error('values', $error, [$attribute->label, $values]);
}
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ public function checkRequiredAttributes(Validation $validation, $attributes, $da
{
$stage = $this->stage_repo->get($stage_id);
// If a required attribute isn't completed, throw an error
$validation->error('values', 'attributeRequired', [$attr->key, $stage->label]);
$validation->error('values', 'attributeRequired', [$attr->label, $stage->label]);
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions application/messages/post.php
Expand Up @@ -21,16 +21,16 @@
'stageRequired' => 'Stage ":param1" is required before publishing',

'values' => [
'date' => ':field.:param1 must be a date, Given: :param2',
'decimal' => ':field.:param1 must be a decimal with 2 places, Given: :param2',
'digit' => ':field.:param1 must be a digit, Given: :param2',
'email' => ':field.:param1 must be an email address, Given: :param2',
'exists' => ':field.:param1 must be a valid post id, Post id: :param2',
'max_length' => ':field.:param1 must not exceed :param2 characters long, Given: :param2',
'invalidForm' => ':field.:param1 has the wrong post type, Post id: :param2',
'numeric' => ':field.:param1 must be numeric, Given: :param2',
'scalar' => ':field.:param1 must be scalar, Given: :param2',
'point' => ':field.:param1 must be an array of lat and lon',
'url' => ':field.:param1 must be a url, Given: :param2',
'date' => 'The field :param1 must be a date, Given: :param2',
'decimal' => 'The field :param1 must be a decimal with 2 places, Given: :param2',
'digit' => 'The field :param1 must be a digit, Given: :param2',
'email' => 'The field :param1 must be an email address, Given: :param2',
'exists' => 'The field :param1 must be a valid post id, Post id: :param2',
'max_length' => 'The field :param1 must not exceed :param2 characters long, Given: :param2',
'invalidForm' => 'The field :param1 has the wrong post type, Post id: :param2',
'numeric' => 'The field :param1 must be numeric, Given: :param2',
'scalar' => 'The field :param1 must be scalar, Given: :param2',
'point' => 'The field :param1 must be an array of lat and lon',
'url' => 'The field :param1 must be a url, Given: :param2',
]
];

0 comments on commit df8d2d3

Please sign in to comment.