mirror of
https://github.com/Respect/Validation.git
synced 2024-06-13 11:12:18 +02:00
3145426472
With that update, we will be fully following PSR-12. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
Jonathan Stewmon <jstewmon@rmn.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
try {
|
|
v::create()
|
|
->key(
|
|
'mysql',
|
|
v::create()
|
|
->key('host', v::stringType(), true)
|
|
->key('user', v::stringType(), true)
|
|
->key('password', v::stringType(), true)
|
|
->key('schema', v::stringType(), true),
|
|
true
|
|
)
|
|
->key(
|
|
'postgresql',
|
|
v::create()
|
|
->key('host', v::stringType(), true)
|
|
->key('user', v::stringType(), true)
|
|
->key('password', v::stringType(), true)
|
|
->key('schema', v::stringType(), true),
|
|
true
|
|
)
|
|
->setName('the given data')
|
|
->assert([
|
|
'mysql' => [
|
|
'host' => 42,
|
|
'user' => 'user',
|
|
'password' => 'password',
|
|
'schema' => 'schema',
|
|
],
|
|
'postgresql' => [
|
|
'host' => 'host',
|
|
'user' => 42,
|
|
'password' => 'password',
|
|
'schema' => 'schema',
|
|
],
|
|
]);
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage() . PHP_EOL;
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
- All of the required rules must pass for the given data
|
|
- These rules must pass for mysql
|
|
- host must be of type string
|
|
- These rules must pass for postgresql
|
|
- user must be of type string
|