respect-validation/tests/integration/rules/creditCard.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

44 lines
1.1 KiB
PHP

--CREDITS--
William Espindola <oi@williamespindola.com.br>
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\CreditCardException;
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator as v;
try {
v::creditCard('Discover')->check(3566002020360505);
} catch (CreditCardException $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
v::not(v::creditCard('Visa'))->check(4024007153361885);
} catch (CreditCardException $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
v::creditCard('MasterCard')->assert(3566002020360505);
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
try {
v::not(v::creditCard())->assert(5555444433331111);
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
?>
--EXPECT--
3566002020360505 must be a valid "Discover" Credit Card number
4024007153361885 must not be a valid "Visa" Credit Card number
- 3566002020360505 must be a valid "MasterCard" Credit Card number
- 5555444433331111 must not be a valid Credit Card number