mirror of
https://github.com/Respect/Validation.git
synced 2024-06-04 14:52:17 +02:00
Update version of "respect/coding-standard"
With that update, we will be fully following PSR-12. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
34cbed2c9b
commit
3145426472
|
@ -20,7 +20,6 @@
|
|||
"symfony/polyfill-mbstring": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
|
||||
"egulias/email-validator": "^2.1",
|
||||
"malukenho/docheader": "^0.1",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
|
@ -28,7 +27,7 @@
|
|||
"phpstan/phpstan-deprecation-rules": "^0.11.0",
|
||||
"phpstan/phpstan-phpunit": "^0.11.0",
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"respect/coding-standard": "^1.0",
|
||||
"respect/coding-standard": "^2.1",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"symfony/validator": "^3.0||^4.0",
|
||||
"zendframework/zend-validator": "^2.1"
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Exceptions;
|
|||
use IteratorAggregate;
|
||||
use RecursiveIteratorIterator;
|
||||
use SplObjectStorage;
|
||||
|
||||
use function array_shift;
|
||||
use function count;
|
||||
use function current;
|
||||
|
@ -24,6 +25,7 @@ use function is_array;
|
|||
use function spl_object_hash;
|
||||
use function sprintf;
|
||||
use function str_repeat;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Exceptions;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use Respect\Validation\Message\Formatter;
|
||||
|
||||
use function key;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ use Respect\Validation\Exceptions\ValidationException;
|
|||
use Respect\Validation\Message\Formatter;
|
||||
use Respect\Validation\Message\ParameterStringifier;
|
||||
use Respect\Validation\Message\Stringifier\KeepOriginalStringName;
|
||||
|
||||
use function lcfirst;
|
||||
use function sprintf;
|
||||
use function trim;
|
||||
|
@ -132,7 +133,7 @@ final class Factory
|
|||
try {
|
||||
/** @var Validatable $rule */
|
||||
$rule = $this
|
||||
->createReflectionClass($namespace.'\\'.ucfirst($ruleName), Validatable::class)
|
||||
->createReflectionClass($namespace . '\\' . ucfirst($ruleName), Validatable::class)
|
||||
->newInstanceArgs($arguments);
|
||||
|
||||
return $rule;
|
||||
|
@ -165,7 +166,7 @@ final class Factory
|
|||
foreach ($this->exceptionsNamespaces as $namespace) {
|
||||
try {
|
||||
return $this->createValidationException(
|
||||
$namespace.'\\'.$ruleName.'Exception',
|
||||
$namespace . '\\' . $ruleName . 'Exception',
|
||||
$id,
|
||||
$input,
|
||||
$params,
|
||||
|
|
|
@ -17,6 +17,7 @@ use Countable;
|
|||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Throwable;
|
||||
|
||||
use function is_numeric;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Helpers;
|
|||
|
||||
use stdClass;
|
||||
use Traversable;
|
||||
|
||||
use function is_array;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Helpers;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function file_exists;
|
||||
use function file_get_contents;
|
||||
use function json_decode;
|
||||
|
@ -28,7 +29,7 @@ final class Subdivisions
|
|||
|
||||
public function __construct(string $countryCode)
|
||||
{
|
||||
$filename = __DIR__.'/../../data/iso_3166-2/'.$countryCode.'.json';
|
||||
$filename = __DIR__ . '/../../data/iso_3166-2/' . $countryCode . '.json';
|
||||
if (!file_exists($filename)) {
|
||||
throw new ComponentException(sprintf('"%s" is not a supported country code', $countryCode));
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Message\Stringifier;
|
||||
|
||||
use Respect\Validation\Message\ParameterStringifier;
|
||||
|
||||
use function is_string;
|
||||
use function Respect\Stringifier\stringify;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
|
||||
use function date;
|
||||
use function date_parse_from_format;
|
||||
use function is_scalar;
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Rules;
|
|||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function array_filter;
|
||||
use function array_map;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Rules;
|
|||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function is_scalar;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\CanValidateUndefined;
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\AnyOfException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use ArrayAccess;
|
||||
use SimpleXMLElement;
|
||||
|
||||
use function is_array;
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Rules;
|
|||
use ReflectionException;
|
||||
use ReflectionProperty;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function is_object;
|
||||
use function property_exists;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function is_null;
|
||||
use function mb_strlen;
|
||||
use function mb_substr;
|
||||
|
@ -62,6 +63,6 @@ final class Base extends AbstractRule
|
|||
{
|
||||
$valid = mb_substr($this->chars, 0, $this->base);
|
||||
|
||||
return (bool) preg_match('@^['.$valid.']+$@', (string) $input);
|
||||
return (bool) preg_match('@^[' . $valid . ']+$@', (string) $input);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use function filter_var;
|
||||
use function is_bool;
|
||||
|
||||
use const FILTER_NULL_ON_FAILURE;
|
||||
use const FILTER_VALIDATE_BOOLEAN;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Rules;
|
|||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validatable;
|
||||
use Throwable;
|
||||
|
||||
use function call_user_func;
|
||||
use function restore_error_handler;
|
||||
use function set_error_handler;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_diff;
|
||||
use function in_array;
|
||||
use function mb_detect_encoding;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Countable as CountableInterface;
|
||||
|
||||
use function is_array;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_column;
|
||||
use function array_keys;
|
||||
use function implode;
|
||||
|
|
|
@ -37,7 +37,7 @@ final class Cpf extends AbstractRule
|
|||
// Code ported from jsfromhell.com
|
||||
$c = preg_replace('/\D/', '', $input);
|
||||
|
||||
if (mb_strlen($c) != 11 || preg_match('/^'.$c[0].'{11}$/', $c) || $c === '01234567890') {
|
||||
if (mb_strlen($c) != 11 || preg_match('/^' . $c[0] . '{11}$/', $c) || $c === '01234567890') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_keys;
|
||||
use function implode;
|
||||
use function is_scalar;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
|
||||
use function date;
|
||||
use function is_scalar;
|
||||
use function preg_match;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use DateTimeInterface;
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
|
||||
use function date;
|
||||
use function is_scalar;
|
||||
use function strtotime;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Directory as NativeDirectory;
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_dir;
|
||||
use function is_scalar;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ use Respect\Validation\Exceptions\DomainException;
|
|||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function array_merge;
|
||||
use function array_pop;
|
||||
use function count;
|
||||
|
|
|
@ -15,9 +15,11 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
|
||||
use function class_exists;
|
||||
use function filter_var;
|
||||
use function is_string;
|
||||
|
||||
use const FILTER_VALIDATE_EMAIL;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use function filter_var;
|
||||
|
||||
use const FILTER_VALIDATE_INT;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_executable;
|
||||
use function is_scalar;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function file_exists;
|
||||
use function is_string;
|
||||
|
||||
|
|
|
@ -14,8 +14,10 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_string;
|
||||
use function pathinfo;
|
||||
|
||||
use const PATHINFO_EXTENSION;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use function filter_var;
|
||||
|
||||
use const FILTER_NULL_ON_FAILURE;
|
||||
use const FILTER_VALIDATE_BOOLEAN;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_file;
|
||||
use function is_string;
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function in_array;
|
||||
|
||||
use const FILTER_VALIDATE_BOOLEAN;
|
||||
use const FILTER_VALIDATE_EMAIL;
|
||||
use const FILTER_VALIDATE_FLOAT;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use function filter_var;
|
||||
use function is_float;
|
||||
|
||||
use const FILTER_VALIDATE_FLOAT;
|
||||
|
||||
/**
|
||||
|
|
|
@ -125,7 +125,7 @@ final class Iban extends AbstractRule
|
|||
|
||||
$checkDigits = substr($iban, 2, 2);
|
||||
$bban = substr($iban, 4);
|
||||
$rearranged = $bban.$countryCode.$checkDigits;
|
||||
$rearranged = $bban . $countryCode . $checkDigits;
|
||||
|
||||
return bcmod($this->convertToInteger($rearranged), '97') === '1';
|
||||
}
|
||||
|
|
|
@ -15,9 +15,11 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use finfo;
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_file;
|
||||
use function is_string;
|
||||
use function mb_strpos;
|
||||
|
||||
use const FILEINFO_MIME_TYPE;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function bccomp;
|
||||
use function explode;
|
||||
use function filter_var;
|
||||
|
@ -26,6 +27,7 @@ use function sprintf;
|
|||
use function str_repeat;
|
||||
use function str_replace;
|
||||
use function strtr;
|
||||
|
||||
use const FILTER_VALIDATE_IP;
|
||||
|
||||
/**
|
||||
|
@ -104,11 +106,11 @@ final class Ip extends AbstractRule
|
|||
private function createRange(): ?string
|
||||
{
|
||||
if ($this->endAddress && $this->endAddress) {
|
||||
return $this->startAddress.'-'.$this->endAddress;
|
||||
return $this->startAddress . '-' . $this->endAddress;
|
||||
}
|
||||
|
||||
if ($this->startAddress && $this->mask) {
|
||||
return $this->startAddress.'/'.long2ip((int) $this->mask);
|
||||
return $this->startAddress . '/' . long2ip((int) $this->mask);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -151,7 +153,7 @@ final class Ip extends AbstractRule
|
|||
|
||||
private function fillAddress(string $address, string $fill = '*'): string
|
||||
{
|
||||
return $address.str_repeat('.'.$fill, 3 - mb_substr_count($address, '.'));
|
||||
return $address . str_repeat('.' . $fill, 3 - mb_substr_count($address, '.'));
|
||||
}
|
||||
|
||||
private function parseRangeUsingWildcards(string $input): void
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Rules;
|
|||
use function is_string;
|
||||
use function json_decode;
|
||||
use function json_last_error;
|
||||
|
||||
use const JSON_ERROR_NONE;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function array_key_exists;
|
||||
use function is_array;
|
||||
use function is_scalar;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use ArrayAccess;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_shift;
|
||||
use function explode;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_map;
|
||||
use function count;
|
||||
|
@ -97,8 +98,7 @@ final class KeySet extends AbstractWrapper
|
|||
return $validatable;
|
||||
}
|
||||
|
||||
if (!$validatable instanceof AllOf
|
||||
|| count($validatable->getRules()) !== 1) {
|
||||
if (!$validatable instanceof AllOf || count($validatable->getRules()) !== 1) {
|
||||
throw new ComponentException('KeySet rule accepts only Key rules');
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ use Respect\Validation\Exceptions\ComponentException;
|
|||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Factory;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function array_keys;
|
||||
use function in_array;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_column;
|
||||
use function array_filter;
|
||||
use function array_search;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
|
||||
use function is_scalar;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use DateTimeInterface;
|
||||
|
||||
use function date;
|
||||
use function is_numeric;
|
||||
use function is_scalar;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Countable as CountableInterface;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function count;
|
||||
use function get_object_vars;
|
||||
use function is_array;
|
||||
|
|
|
@ -15,8 +15,10 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use finfo;
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_file;
|
||||
use function is_string;
|
||||
|
||||
use const FILEINFO_MIME_TYPE;
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,11 +65,11 @@ final class Nif extends AbstractRule
|
|||
private function validateNie(string $prefix, string $number, string $control): bool
|
||||
{
|
||||
if ($prefix === 'Y') {
|
||||
return $this->validateDni((int) ('1'.$number), $control);
|
||||
return $this->validateDni((int) ('1' . $number), $control);
|
||||
}
|
||||
|
||||
if ($prefix === 'Z') {
|
||||
return $this->validateDni((int) ('2'.$number), $control);
|
||||
return $this->validateDni((int) ('2' . $number), $control);
|
||||
}
|
||||
|
||||
return $this->validateDni((int) $number, $control);
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use function nl_langinfo;
|
||||
|
||||
use const NOEXPR;
|
||||
|
||||
/**
|
||||
|
@ -30,6 +31,6 @@ final class No extends AbstractEnvelope
|
|||
$pattern = nl_langinfo(NOEXPR);
|
||||
}
|
||||
|
||||
parent::__construct(new Regex('/'.$pattern.'/i'));
|
||||
parent::__construct(new Regex('/' . $pattern . '/i'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\NoneOfException;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function array_shift;
|
||||
use function count;
|
||||
use function current;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use stdClass;
|
||||
|
||||
use function array_filter;
|
||||
use function is_array;
|
||||
use function is_numeric;
|
||||
|
|
|
@ -205,6 +205,6 @@ final class NotEmoji extends AbstractRule
|
|||
return false;
|
||||
}
|
||||
|
||||
return preg_match('/'.implode('|', self::RANGES).'/mu', $input) === 0;
|
||||
return preg_match('/' . implode('|', self::RANGES) . '/mu', $input) === 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use function filter_var;
|
||||
use function is_numeric;
|
||||
|
||||
use const FILTER_VALIDATE_INT;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\OneOfException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
|
||||
use function array_shift;
|
||||
use function count;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ final class Pis extends AbstractRule
|
|||
}
|
||||
|
||||
$digits = preg_replace('/\D/', '', $input);
|
||||
if (mb_strlen($digits) != 11 || preg_match('/^'.$digits[0].'{11}$/', $digits)) {
|
||||
if (mb_strlen($digits) != 11 || preg_match('/^' . $digits[0] . '{11}$/', $digits)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_readable;
|
||||
use function is_string;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ use Symfony\Component\Validator\Constraint;
|
|||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use SplFileInfo;
|
||||
|
||||
use function filesize;
|
||||
use function is_numeric;
|
||||
use function is_string;
|
||||
|
@ -87,7 +88,7 @@ final class Size extends AbstractRule
|
|||
$value = $size;
|
||||
$units = ['b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb'];
|
||||
foreach ($units as $exponent => $unit) {
|
||||
if (!preg_match('/^(\d+(.\d+)?)'.$unit.'$/i', (string) $size, $matches)) {
|
||||
if (!preg_match('/^(\d+(.\d+)?)' . $unit . '$/i', (string) $size, $matches)) {
|
||||
continue;
|
||||
}
|
||||
$value = $matches[1] * 1024 ** $exponent;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function is_array;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\Subdivisions;
|
||||
|
||||
use function array_keys;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_link;
|
||||
use function is_string;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
|
||||
use function date;
|
||||
use function is_scalar;
|
||||
use function preg_match;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use function filter_var;
|
||||
|
||||
use const FILTER_NULL_ON_FAILURE;
|
||||
use const FILTER_VALIDATE_BOOLEAN;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_keys;
|
||||
use function gettype;
|
||||
use function implode;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use function array_unique;
|
||||
use function is_array;
|
||||
|
||||
use const SORT_REGULAR;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_scalar;
|
||||
use function is_uploaded_file;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use const FILTER_VALIDATE_URL;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function is_string;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function array_keys;
|
||||
use function is_string;
|
||||
use function mb_strtolower;
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
use function is_string;
|
||||
use function is_writable;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Respect\Validation\Rules;
|
|||
use function is_string;
|
||||
use function nl_langinfo;
|
||||
use function preg_match;
|
||||
|
||||
use const YESEXPR;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +55,7 @@ final class Yes extends AbstractRule
|
|||
private function getPattern(): string
|
||||
{
|
||||
if ($this->useLocale) {
|
||||
return '/'.nl_langinfo(YESEXPR).'/';
|
||||
return '/' . nl_langinfo(YESEXPR) . '/';
|
||||
}
|
||||
|
||||
return '/^y(eah?|ep|es)?$/i';
|
||||
|
|
|
@ -19,6 +19,7 @@ use Respect\Validation\Exceptions\ValidationException;
|
|||
use Respect\Validation\Exceptions\ZendException;
|
||||
use Throwable;
|
||||
use Zend\Validator\ValidatorInterface;
|
||||
|
||||
use function array_map;
|
||||
use function current;
|
||||
use function is_string;
|
||||
|
@ -121,7 +122,7 @@ final class Zend extends AbstractRule
|
|||
throw new ComponentException('The given argument is not a valid Zend Validator');
|
||||
}
|
||||
|
||||
$className = stripos($validator, 'Zend') === false ? 'Zend\\Validator\\'.$validator : '\\'.$validator;
|
||||
$className = stripos($validator, 'Zend') === false ? 'Zend\\Validator\\' . $validator : '\\' . $validator;
|
||||
|
||||
try {
|
||||
$reflection = new ReflectionClass($className);
|
||||
|
|
|
@ -20,6 +20,7 @@ use Respect\Validation\Rules\AllOf;
|
|||
use Respect\Validation\Rules\Key;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ try {
|
|||
->setName('the given data')
|
||||
->assert($object);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -42,7 +42,7 @@ try {
|
|||
],
|
||||
]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -21,7 +21,7 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::each(v::equals(1))->assert(['A', 'B', 'B']);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -58,7 +58,7 @@ $input = [
|
|||
try {
|
||||
$validator->check($input);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,7 @@ $validator->key('schema', v::stringType());
|
|||
try {
|
||||
$validator->assert($config);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -47,7 +47,7 @@ try {
|
|||
],
|
||||
]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -21,7 +21,7 @@ try {
|
|||
)
|
||||
->assert($input);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -34,7 +34,7 @@ try {
|
|||
)
|
||||
->assert($input);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -26,13 +26,13 @@ $validator = v::not(
|
|||
try {
|
||||
$validator->check(2);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
$validator->assert(2);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -18,7 +18,7 @@ try {
|
|||
);
|
||||
$validator->check(2);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -14,49 +14,49 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::alnum()->check('abc%1');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alnum(' ')->check('abc%2');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum())->check('abcd3');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum('% '))->check('abc%4');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alnum()->assert('abc^1');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum())->assert('abcd2');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alnum('* &%')->assert('abc^3');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum('^'))->assert('abc^4');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -14,49 +14,49 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::alpha()->check('aaa%a');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alpha(' ')->check('bbb%b');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha())->check('ccccc');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha('% '))->check('ddd%d');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alpha()->assert('eee^e');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha())->assert('fffff');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alpha('* &%')->assert('ggg^g');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha('^'))->assert('hhh^h');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -14,13 +14,13 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::alwaysInvalid()->check('whatever');
|
||||
} catch (AlwaysInvalidException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alwaysInvalid()->assert('');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -14,13 +14,13 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::not(v::alwaysValid())->check(true);
|
||||
} catch (AlwaysValidException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alwaysValid())->assert(true);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -15,25 +15,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::arrayType()->check('teste');
|
||||
} catch (ArrayTypeException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayType())->check([]);
|
||||
} catch (ArrayTypeException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::arrayType()->assert(new ArrayObject());
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayType())->assert([1, 2, 3]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -15,25 +15,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::arrayVal()->check('Bla %123');
|
||||
} catch (ArrayValException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayVal())->check([42]);
|
||||
} catch (ArrayValException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::arrayVal()->assert(new stdClass());
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayVal())->assert(new ArrayObject([2, 3]));
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -14,25 +14,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::base(61)->check('Z01xSsg5675hic20dj');
|
||||
} catch (BaseException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::base(2)->assert('');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base(2))->check('011010001');
|
||||
} catch (BaseException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base(2))->assert('011010001');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -16,25 +16,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::base64()->check('=c3VyZS4');
|
||||
} catch (Base64Exception $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base64())->check('c3VyZS4=');
|
||||
} catch (Base64Exception $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::base64()->assert('=c3VyZS4');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base64())->assert('c3VyZS4=');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -14,25 +14,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::between(1, 2)->check(0);
|
||||
} catch (BetweenException $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::between('yesterday', 'tomorrow'))->check('today');
|
||||
} catch (BetweenException $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::between('a', 'c')->assert('d');
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage().PHP_EOL;
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::between(-INF, INF))->assert(0);
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage().PHP_EOL;
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -14,25 +14,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::boolType()->check('teste');
|
||||
} catch (BoolTypeException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolType())->check(true);
|
||||
} catch (BoolTypeException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::boolType()->assert([]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolType())->assert(false);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -16,25 +16,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::boolVal()->check('ok');
|
||||
} catch (BoolValException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolVal())->check('yes');
|
||||
} catch (BoolValException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::boolVal()->assert('yep');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolVal())->assert('on');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -14,25 +14,25 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::bsn()->check('acb');
|
||||
} catch (BsnException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::bsn())->check('612890053');
|
||||
} catch (BsnException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::bsn()->assert('abc');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::bsn())->assert('612890053');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -15,37 +15,37 @@ use Respect\Validation\Validator as v;
|
|||
try {
|
||||
v::call('trim', v::noWhitespace())->check(' two words ');
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::call('trim', v::stringType()))->check(' something ');
|
||||
} catch (CallException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::call('trim', v::alwaysValid())->check([]);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::call('strval', v::intType())->assert(1234);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::call('is_float', v::boolType()))->assert(1.2);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::call('array_walk', v::alwaysValid())->assert(INF);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue