Update version and improve config validation

This commit is contained in:
netkas 2024-09-26 14:57:27 -04:00
parent 698e2cb334
commit 2f41614d20
3 changed files with 5 additions and 5 deletions

View file

@ -35,7 +35,7 @@
"company": "Nosial", "company": "Nosial",
"copyright": "Copyright (c) 2022-2023 Nosial", "copyright": "Copyright (c) 2022-2023 Nosial",
"description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API",
"version": "1.1.0", "version": "1.1.1",
"uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35"
}, },
"build": { "build": {

View file

@ -161,9 +161,7 @@
*/ */
private static function validateKey(string $input): bool private static function validateKey(string $input): bool
{ {
$pattern = '/^([a-zA-Z0-9]+\.?)+$/'; if (preg_match('/^([a-zA-Z0-9_]+\.?)+$/', $input))
if (preg_match($pattern, $input))
{ {
return true; return true;
} }

View file

@ -52,8 +52,10 @@ class ConfigurationTest extends TestCase
public function testGetMethodWithValidKey(): void public function testGetMethodWithValidKey(): void
{ {
$config = new Configuration('test'); $config = new Configuration('test');
$config->set('key1.key2', 'value'); $this->assertTrue($config->set('key1.key2', 'value', true));
$this->assertEquals('value', $config->get('key1.key2')); $this->assertEquals('value', $config->get('key1.key2'));
$this->assertTrue($config->set('foo.fizz_buzz', 'value', true));
$this->assertEquals('value', $config->get('foo.fizz_buzz'));
} }
/** /**