mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
26 lines
736 B
PHP
26 lines
736 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) {
|
|
print_r($exception->getMessages());
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Array
|
|
(
|
|
[alnum] => "really messed up screen#name" must contain only letters (a-z) and digits (0-9)
|
|
[noWhitespace] => "really messed up screen#name" must not contain whitespace
|
|
[length] => "really messed up screen#name" must have a length between 1 and 15
|
|
)
|