respect-validation/tests/integration/rules/email.phpt
Henrique Moody cc20a442a1
Apply "SlevomatCodingStandard.TypeHints.DeclareStrictTypes"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:11:12 +01:00

42 lines
974 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