mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
25 lines
757 B
PHP
25 lines
757 B
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
|
|
try {
|
|
$usernameValidator->assert('really messed up screen#name');
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage();
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
- All of the required rules must pass for "really messed up screen#name"
|
|
- "really messed up screen#name" must contain only letters (a-z) and digits (0-9)
|
|
- "really messed up screen#name" must not contain whitespace
|
|
- "really messed up screen#name" must have a length between 1 and 15
|