2018-11-30 09:25:42 +01:00
|
|
|
--CREDITS--
|
|
|
|
Henrique Moody <henriquemoody@gmail.com>
|
2015-10-22 04:30:30 +02:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
2019-02-09 11:44:33 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2015-10-22 04:30:30 +02:00
|
|
|
require 'vendor/autoload.php';
|
|
|
|
|
|
|
|
use Respect\Validation\Exceptions\AllOfException;
|
|
|
|
use Respect\Validation\Validator as v;
|
|
|
|
|
|
|
|
$config = [
|
2018-07-09 09:24:08 +02:00
|
|
|
'host' => 1,
|
2015-10-22 04:30:30 +02:00
|
|
|
'password' => 'my_password',
|
|
|
|
'schema' => 'my_schema',
|
|
|
|
];
|
|
|
|
|
2019-02-04 00:29:13 +01:00
|
|
|
$validator = v::arrayType();
|
|
|
|
$validator->setName('Settings');
|
|
|
|
$validator->key('host', v::stringType());
|
|
|
|
$validator->key('user', v::stringType());
|
|
|
|
$validator->key('password', v::stringType());
|
|
|
|
$validator->key('schema', v::stringType());
|
2015-10-22 04:30:30 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
$validator->assert($config);
|
|
|
|
} catch (AllOfException $exception) {
|
2020-07-21 22:54:41 +02:00
|
|
|
echo $exception->getFullMessage() . PHP_EOL;
|
2015-10-22 04:30:30 +02:00
|
|
|
}
|
|
|
|
?>
|
2018-12-19 18:05:58 +01:00
|
|
|
--EXPECT--
|
2018-07-09 09:24:08 +02:00
|
|
|
- These rules must pass for Settings
|
|
|
|
- host must be of type string
|
2019-07-05 03:02:08 +02:00
|
|
|
- user must be present
|