ash-jc-allen / laravel-config-validator

A library for validating your Laravel app's config.
MIT License
200 stars 11 forks source link

Fix nested config #66

Closed ash-jc-allen closed 6 months ago

ash-jc-allen commented 6 months ago

Currently, there is a bug that prevents deep-nested config fields from being validated. This is down to the way I was reading the config files and adding their values to the ValidationRepository. If a field was nested more than 2 times, only the first field at that level would be added to the repository.

For example, say we have this short-url config field:

return [
    'prefix' => 'short',

    'tracking' => [
        'fields' => [
            'ip_address' => true,
            'operating_system' => true,
        ],
    ],
];

In this instance, the ValidationRepository would only load the following values:

short-url.tracking.fields.operating_system's value would not be loaded. This means the field couldn't be validated as expected.