mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 06:12:17 +02:00
3145426472
With that update, we will be fully following PSR-12. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
43 lines
982 B
PHP
43 lines
982 B
PHP
--CREDITS--
|
|
Paul Karikari <paulkarikari1@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\EmailException;
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
try {
|
|
v::email()->check('batman');
|
|
} catch (EmailException $e) {
|
|
echo $e->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::email())->check('bruce.wayne@gothancity.com');
|
|
} catch (EmailException $e) {
|
|
echo $e->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::email()->assert('bruce wayne');
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::email())->assert('iambatman@gothancity.com');
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage() . PHP_EOL;
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
"batman" must be valid email
|
|
"bruce.wayne@gothancity.com" must not be an email
|
|
- "bruce wayne" must be valid email
|
|
- "iambatman@gothancity.com" must not be an email
|