KaneCohen/laravel-validation — pull request #1 by sandyandi (2014-06-14 06:03:39+00:00)
Title: Added getAttribute() so custom attributes with dynamic index can be pulled from validation language file.

Added getAttribute() so custom attributes with dynamic index can be pulled from validation language file.

Example:

$data = array('income_sources' => array(
array(
'type' => 'employment',
'employer_name' => '',
'employer_phone' => 'Bar',
),
array(
'type' => 'business',
'business_name' => '',
'business_nature' => 'Boom',
),
));

$rules = array(
'income_sources:0:employer_name' => 'required',
'income_sources:1:business_name' => 'required',
);

...and I have the following in my language file (`app/lang/en/validation.php`):

'attributes' => array(
'income_sources:employer_name' => 'employer name',
'income_sources:business_name' => 'business name'
)

It will have an error message something like: `The employer name is required.` instead of something like `The income sources:1:employer name is required.`

Sometimes we need to specify index in our data like the above.