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

20 lines
417 B
PHP

--CREDITS--
Henrique Moody <henriquemoody@gmail.com>
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\OptionalException;
use Respect\Validation\Validator as v;
try {
v::not(v::optional(v::equals('foo'))->setName('My field'))->check(null);
} catch (OptionalException $e) {
echo $e->getMessage().PHP_EOL;
}
?>
--EXPECT--
My field must not be optional