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>
44 lines
1.1 KiB
PHP
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
|