respect-validation/tests/integration/rules/email.phpt
Henrique Moody 3145426472
Update version of "respect/coding-standard"
With that update, we will be fully following PSR-12.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-07-21 22:54:41 +02:00

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