Laravel version update
Laravel version update
This commit is contained in:
229
vendor/zendframework/zend-validator/CHANGELOG.md
vendored
229
vendor/zendframework/zend-validator/CHANGELOG.md
vendored
@@ -2,6 +2,235 @@
|
||||
|
||||
All notable changes to this project will be documented in this file, in reverse chronological order by release.
|
||||
|
||||
## 2.10.2 - 2018-02-01
|
||||
|
||||
### Added
|
||||
|
||||
- [#202](https://github.com/zendframework/zend-validator/pull/202) adds the
|
||||
ability to use custom constant types in extensions of
|
||||
`Zend\Validator\CreditCard`, fixing an issue where users were unable to add
|
||||
new brands as they are created.
|
||||
|
||||
- [#203](https://github.com/zendframework/zend-validator/pull/203) adds support
|
||||
for the new Russian bank card "Mir".
|
||||
|
||||
- [#204](https://github.com/zendframework/zend-validator/pull/204) adds support
|
||||
to the IBAN validator for performing SEPA validation against Croatia and San
|
||||
Marino.
|
||||
|
||||
- [#209](https://github.com/zendframework/zend-validator/pull/209) adds
|
||||
documentation for the `Explode` validator.
|
||||
|
||||
### Changed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#195](https://github.com/zendframework/zend-validator/pull/195) adds
|
||||
missing `GpsPoint` validator entries to the `ValidatorPluginManager`, ensuring
|
||||
they may be retrieved from it correctly.
|
||||
|
||||
- [#212](https://github.com/zendframework/zend-validator/pull/212) updates the
|
||||
`CSRF` validator to automatically mark any non-string values as invalid,
|
||||
preventing errors such as array to string conversion.
|
||||
|
||||
## 2.10.1 - 2017-08-22
|
||||
|
||||
### Added
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Changed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#194](https://github.com/zendframework/zend-validator/pull/194) modifies the
|
||||
`EmailAddress` validator to omit the `INTL_IDNA_VARIANT_UTS46` flag to
|
||||
`idn_to_utf8()` if the constant is not defined, fixing an issue on systems
|
||||
using pre-2012 releases of libicu.
|
||||
|
||||
## 2.10.0 - 2017-08-14
|
||||
|
||||
### Added
|
||||
|
||||
- [#175](https://github.com/zendframework/zend-validator/pull/175) adds support
|
||||
for PHP 7.2 (conditionally, as PHP 7.2 is currently in beta1).
|
||||
|
||||
- [#157](https://github.com/zendframework/zend-validator/pull/157) adds a new
|
||||
validator, `IsCountable`, which allows validating:
|
||||
- if a value is countable
|
||||
- if a countable value exactly matches a configured count
|
||||
- if a countable value is greater than a configured minimum count
|
||||
- if a countable value is less than a configured maximum count
|
||||
- if a countable value is between configured minimum and maximum counts
|
||||
|
||||
### Changed
|
||||
|
||||
- [#169](https://github.com/zendframework/zend-validator/pull/169) modifies how
|
||||
the various `File` validators check for readable files. Previously, they used
|
||||
`stream_resolve_include_path`, which led to false negative checks when the
|
||||
files did not exist within an `include_path` (which is often the case within a
|
||||
web application). These now use `is_readable()` instead.
|
||||
|
||||
- [#185](https://github.com/zendframework/zend-validator/pull/185) updates the
|
||||
zend-session requirement (during development, and in the suggestions) to 2.8+,
|
||||
to ensure compatibility with the upcoming PHP 7.2 release.
|
||||
|
||||
- [#187](https://github.com/zendframework/zend-validator/pull/187) updates the
|
||||
`Between` validator to **require** that both a `min` and a `max` value are
|
||||
provided to the constructor, and that both are of the same type (both
|
||||
integer/float values and/or both string values). This fixes issues that could
|
||||
previously occur when one or the other was not set, but means an exception
|
||||
will now be raised during instantiation (versus runtime during `isValid()`).
|
||||
|
||||
- [#188](https://github.com/zendframework/zend-validator/pull/188) updates the
|
||||
`ConfigProvider` to alias the service name `ValidatorManager` to the class
|
||||
`Zend\Validator\ValidatorPluginManager`, and now maps the the latter class to
|
||||
the `ValidatorPluginManagerFactory`. Previously, we mapped the service name
|
||||
directly to the factory. Usage should not change for anybody at this point.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- [#175](https://github.com/zendframework/zend-validator/pull/175) removes
|
||||
support for HHVM.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#160](https://github.com/zendframework/zend-validator/pull/160) fixes how the
|
||||
`EmailAddress` validator handles the local part of an address, allowing it to
|
||||
support unicode.
|
||||
|
||||
## 2.9.2 - 2017-07-20
|
||||
|
||||
### Added
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#180](https://github.com/zendframework/zend-validator/pull/180) fixes how
|
||||
`Zend\Validator\File\MimeType` "closes" the open FileInfo handle for the file
|
||||
being validated, using `unset()` instead of `finfo_close()`; this resolves a
|
||||
segfault that occurs on older PHP versions.
|
||||
- [#174](https://github.com/zendframework/zend-validator/pull/174) fixes how
|
||||
`Zend\Validator\Between` handles two situations: (1) when a non-numeric value
|
||||
is validated against numeric min/max values, and (2) when a numeric value is
|
||||
validated against non-numeric min/max values. Previously, these incorrectly
|
||||
validated as true; now they are marked invalid.
|
||||
|
||||
## 2.9.1 - 2017-05-17
|
||||
|
||||
### Added
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Changes
|
||||
|
||||
- [#154](https://github.com/zendframework/zend-validator/pull/154) updates the
|
||||
`CreditCard` validator to allow 19 digit Discover card values, and 13 and 19
|
||||
digit Visa card values, which are now allowed (see
|
||||
https://en.wikipedia.org/wiki/Payment_card_number).
|
||||
- [#162](https://github.com/zendframework/zend-validator/pull/162) updates the
|
||||
`Hostname` validator to support `.hr` (Croatia) IDN domains.
|
||||
- [#163](https://github.com/zendframework/zend-validator/pull/163) updates the
|
||||
`Iban` validator to support Belarus.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#168](https://github.com/zendframework/zend-validator/pull/168) fixes how the
|
||||
`ValidatorPluginManagerFactory` factory initializes the plugin manager instance,
|
||||
ensuring it is injecting the relevant configuration from the `config` service
|
||||
and thus seeding it with configured validator services. This means
|
||||
that the `validators` configuration will now be honored in non-zend-mvc contexts.
|
||||
|
||||
## 2.9.0 - 2017-03-17
|
||||
|
||||
### Added
|
||||
|
||||
- [#78](https://github.com/zendframework/zend-validator/pull/78) added
|
||||
`%length%` as an optional message variable in StringLength validator
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- [#151](https://github.com/zendframework/zend-validator/pull/151) dropped
|
||||
php 5.5 support
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#147](https://github.com/zendframework/zend-validator/issues/147)
|
||||
[#148](https://github.com/zendframework/zend-validator/pull/148) adds further
|
||||
`"suggest"` clauses in `composer.json`, since some dependencies are not always
|
||||
required, and may lead to runtime failures.
|
||||
- [#66](https://github.com/zendframework/zend-validator/pull/66) fixed
|
||||
EmailAddress validator applying IDNA conversion to local part
|
||||
- [#88](https://github.com/zendframework/zend-validator/pull/88) fixed NotEmpty
|
||||
validator incorrectly applying types bitmaps
|
||||
- [#150](https://github.com/zendframework/zend-validator/pull/150) fixed Hostname
|
||||
validator not allowing some characters in .dk IDN
|
||||
|
||||
## 2.8.2 - 2017-01-29
|
||||
|
||||
### Added
|
||||
|
||||
- [#110](https://github.com/zendframework/zend-validator/pull/110) adds new
|
||||
Mastercard 2-series BINs
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#81](https://github.com/zendframework/zend-validator/pull/81) registers the
|
||||
Uuid validator into ValidatorPluginManager.
|
||||
|
||||
## 2.8.1 - 2016-06-23
|
||||
|
||||
### Added
|
||||
|
@@ -77,24 +77,24 @@ To do so:
|
||||
|
||||
## Running Coding Standards Checks
|
||||
|
||||
This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
|
||||
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
|
||||
standards checks, and provides configuration for our selected checks.
|
||||
`php-cs-fixer` is installed by default via Composer.
|
||||
`phpcs` is installed by default via Composer.
|
||||
|
||||
To run checks only:
|
||||
|
||||
```console
|
||||
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
|
||||
$ composer cs-check
|
||||
```
|
||||
|
||||
To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
|
||||
flag:
|
||||
`phpcs` also includes a tool for fixing most CS violations, `phpcbf`:
|
||||
|
||||
|
||||
```console
|
||||
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
|
||||
$ composer cs-fix
|
||||
```
|
||||
|
||||
If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
|
||||
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
|
||||
they pass, and make sure you add and commit the changes after verification.
|
||||
|
||||
## Recommended Workflow for Contributions
|
||||
|
@@ -177,7 +177,9 @@ function getNewValidTlds($string)
|
||||
function getPunycodeDecoder()
|
||||
{
|
||||
if (function_exists('idn_to_utf8')) {
|
||||
return 'idn_to_utf8';
|
||||
return function ($domain) {
|
||||
return idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46);
|
||||
};
|
||||
}
|
||||
|
||||
$hostnameValidator = new Hostname();
|
||||
|
@@ -13,8 +13,8 @@
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.5 || ^7.0",
|
||||
"zendframework/zend-stdlib": "^2.7 || ^3.0",
|
||||
"php": "^5.6 || ^7.0",
|
||||
"zendframework/zend-stdlib": "^2.7.6 || ^3.1",
|
||||
"container-interop/container-interop": "^1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -26,27 +26,27 @@
|
||||
"zendframework/zend-i18n": "^2.6",
|
||||
"zendframework/zend-math": "^2.6",
|
||||
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
|
||||
"zendframework/zend-session": "^2.6.2",
|
||||
"zendframework/zend-session": "^2.8",
|
||||
"zendframework/zend-uri": "^2.5",
|
||||
"fabpot/php-cs-fixer": "1.7.*",
|
||||
"phpunit/PHPUnit": "^4.0"
|
||||
"phpunit/PHPUnit": "^6.0.8 || ^5.7.15",
|
||||
"zendframework/zend-coding-standard": "~1.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
"zendframework/zend-db": "Zend\\Db component",
|
||||
"zendframework/zend-db": "Zend\\Db component, required by the (No)RecordExists validator",
|
||||
"zendframework/zend-filter": "Zend\\Filter component, required by the Digits validator",
|
||||
"zendframework/zend-i18n": "Zend\\I18n component to allow translation of validation error messages as well as to use the various Date validators",
|
||||
"zendframework/zend-math": "Zend\\Math component",
|
||||
"zendframework/zend-i18n": "Zend\\I18n component to allow translation of validation error messages",
|
||||
"zendframework/zend-math": "Zend\\Math component, required by the Csrf validator",
|
||||
"zendframework/zend-i18n-resources": "Translations of validator messages",
|
||||
"zendframework/zend-servicemanager": "Zend\\ServiceManager component to allow using the ValidatorPluginManager and validator chains",
|
||||
"zendframework/zend-session": "Zend\\Session component",
|
||||
"zendframework/zend-session": "Zend\\Session component, ^2.8; required by the Csrf validator",
|
||||
"zendframework/zend-uri": "Zend\\Uri component, required by the Uri and Sitemap\\Loc validators"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.8-dev",
|
||||
"dev-develop": "2.9-dev"
|
||||
"dev-master": "2.10.x-dev",
|
||||
"dev-develop": "2.11.x-dev"
|
||||
},
|
||||
"zf": {
|
||||
"component": "Zend\\Validator",
|
||||
@@ -57,5 +57,15 @@
|
||||
"psr-4": {
|
||||
"ZendTest\\Validator\\": "test/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"check": [
|
||||
"@cs-check",
|
||||
"@test"
|
||||
],
|
||||
"cs-check": "phpcs",
|
||||
"cs-fix": "phpcbf",
|
||||
"test": "phpunit --colors=always",
|
||||
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
|
||||
}
|
||||
}
|
||||
|
2293
vendor/zendframework/zend-validator/composer.lock
generated
vendored
Normal file
2293
vendor/zendframework/zend-validator/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,6 @@ The following validators come with the zend-validator distribution.
|
||||
- [IsInstanceOf](validators/isinstanceof.md)
|
||||
- [LessThan](validators/less-than.md)
|
||||
- [NotEmpty](validators/not-empty.md)
|
||||
- [PostCode](validators/post-code.md)
|
||||
- [Regex](validators/regex.md)
|
||||
- [Sitemap](validators/sitemap.md)
|
||||
- [Step](validators/step.md)
|
||||
|
@@ -33,6 +33,7 @@ The following issuing institutes are accepted:
|
||||
- Solo
|
||||
- Visa
|
||||
- Visa Electron
|
||||
- Russia Mir
|
||||
|
||||
> ### Invalid institutes
|
||||
>
|
||||
|
@@ -25,7 +25,7 @@ $validator->isValid('10.10.2000'); // returns false
|
||||
|
||||
`Zend\Validator\Date` also supports custom date formats. When you want to
|
||||
validate such a date, use the `format` option. This option accepts any format
|
||||
allowed by the PHP [date()](http://php.net/date) function.
|
||||
allowed by the PHP [DateTime::createFromFormat()](http://php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters) method.
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\Date(['format' => 'Y']);
|
||||
|
@@ -31,21 +31,26 @@ at instantiation, by giving an array with the related options, or afterwards, by
|
||||
using `setOptions()`. The following options are supported:
|
||||
|
||||
- `allow`: Defines which type of domain names are accepted. This option is used
|
||||
in conjunction with the hostname option to set the hostname validator. For
|
||||
more information about possible values of this option, look at
|
||||
[Hostname](hostname.md) and possible `ALLOW_*` constants. This option
|
||||
defaults to `ALLOW_DNS`.
|
||||
- `deep`: Defines if the servers MX records should be verified by a deep check.
|
||||
in conjunction with the hostnameValidator option to set the hostname validator.
|
||||
Possible values of this option defined in [Hostname](hostname.md) validator's
|
||||
`ALLOW_*` constants:
|
||||
- `ALLOW_DNS` (default) - Allows Internet domain names _(e.g. example.com)_
|
||||
- `ALLOW_IP` - Allows IP addresses _(e.g. 192.168.0.1)_
|
||||
- `ALLOW_LOCAL` - Allows local network such as _localhost_ or _www.localdomain_
|
||||
- `ALLOW_URI` - Allows hostnames in URI generic syntax. See [RFC 3986](https://www.ietf.org/rfc/rfc3986.txt)
|
||||
- `ALLOW_ALL` - Allows all types of hostnames
|
||||
|
||||
- `useDeepMxCheck`: Defines if the servers MX records should be verified by a deep check.
|
||||
When this option is set to `true` then additionally to MX records also the `A`,
|
||||
`A6` and `AAAA` records are used to verify if the server accepts emails. This
|
||||
option defaults to `false`.
|
||||
- `domain`: Defines if the domain part should be checked. When this option is
|
||||
- `useDomainCheck`: Defines if the domain part should be checked. When this option is
|
||||
set to `false`, then only the local part of the email address will be checked.
|
||||
In this case the hostname validator will not be called. This option defaults
|
||||
to `true`.
|
||||
- `hostname`: Sets the hostname validator with which the domain part of the
|
||||
email address will be validated.
|
||||
- `mx`: Defines if the MX records from the server should be detected. If this
|
||||
- `hostnameValidator`: Sets the hostname validator object instance with which the
|
||||
domain part of the email address will be validated.
|
||||
- `useMxCheck`: Defines if the MX records from the server should be detected. If this
|
||||
option is defined to `true` then the MX records are used to verify if the
|
||||
server accepts emails. This option defaults to `false`.
|
||||
|
||||
|
48
vendor/zendframework/zend-validator/doc/book/validators/explode.md
vendored
Normal file
48
vendor/zendframework/zend-validator/doc/book/validators/explode.md
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# Explode Validator
|
||||
|
||||
`Zend\Validator\Explode` executes a validator for each item exploded from an
|
||||
array.
|
||||
|
||||
## Supported options
|
||||
|
||||
The following options are supported for `Zend\Validator\Explode`:
|
||||
|
||||
- `valueDelimiter`: Defines the delimiter used to explode values from an array.
|
||||
It defaults to `,`. If the given value is an array, this option isn't used.
|
||||
- `validator`: Sets the validator that will be executed on each exploded item.
|
||||
This may be a validator instance, or a validator service name.
|
||||
|
||||
## Basic usage
|
||||
|
||||
To validate if every item in an array is in a specified haystack:
|
||||
|
||||
```php
|
||||
$inArrayValidator = new Zend\Validator\InArray([
|
||||
'haystack' => [1, 2, 3, 4, 5, 6],
|
||||
]);
|
||||
|
||||
$explodeValidator = new Zend\Validator\Explode([
|
||||
'validator' => $inArrayValidator
|
||||
]);
|
||||
|
||||
$explodeValidator->isValid([1, 4, 6]); // returns true
|
||||
$explodeValidator->isValid([1, 4, 6, 8]); // returns false
|
||||
```
|
||||
|
||||
## Exploding strings
|
||||
|
||||
To validate if every e-mail in a string is contained in a list of names:
|
||||
|
||||
```php
|
||||
$inEmailListValidator = new Zend\Validator\InArray([
|
||||
'haystack' => ['joseph@test.com', 'mark@test.com', 'lucia@test.com'],
|
||||
]);
|
||||
|
||||
$explodeValidator = new Zend\Validator\Explode([
|
||||
'validator' => $inEmailListValidator,
|
||||
'valueDelimiter' => ','
|
||||
]);
|
||||
|
||||
$explodeValidator->isValid('joseph@test.com,mark@test.com'); // returns true
|
||||
$explodeValidator->isValid('lucia@test.com,maria@test.com'); // returns false
|
||||
```
|
@@ -24,7 +24,7 @@ The following options are supported:
|
||||
$validator = new \Zend\Validator\File\Crc32('3b3652f');
|
||||
|
||||
// Or, check file against multiple hashes
|
||||
$validator = new \Zend\Validator\File\Crc32(array('3b3652f', 'e612b69'));
|
||||
$validator = new \Zend\Validator\File\Crc32(['3b3652f', 'e612b69']);
|
||||
|
||||
// Perform validation with file path
|
||||
if ($validator->isValid('./myfile.txt')) {
|
||||
|
@@ -68,7 +68,7 @@ $form->add([
|
||||
$form->add([
|
||||
'name' => 'elementTwo',
|
||||
'type' => 'Password',
|
||||
'validators' => array(
|
||||
'validators' => [
|
||||
[
|
||||
'name' => 'Identical',
|
||||
'options' => [
|
||||
@@ -136,7 +136,7 @@ $inputFilter = new InputFilter();
|
||||
$inputFilter->add([
|
||||
'name' => 'confirmEmail', // references (5)
|
||||
'validators' => [
|
||||
array(
|
||||
[
|
||||
'name' => 'Identical',
|
||||
'options' => [
|
||||
// 'user' key references 'user' fieldset (1), and 'email'
|
||||
@@ -162,7 +162,7 @@ $inputFilter->add([
|
||||
// 'deeperFieldsetInput' element (4)
|
||||
'deeperFieldset' => 'deeperFieldsetInput',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@@ -7,8 +7,8 @@ within an array. It is also able to validate multidimensional arrays.
|
||||
|
||||
The following options are supported for `Zend\Validator\InArray`:
|
||||
|
||||
- `haystack`: Sets the haystack for the validation. `recursive`: Defines if the
|
||||
- validation should be done recursively. This option
|
||||
- `haystack`: Sets the haystack for the validation.
|
||||
- `recursive`: Defines if the validation should be done recursively. This option
|
||||
defaults to `false`.
|
||||
- `strict`: Three modes of comparison are offered owing to an often overlooked,
|
||||
and potentially dangerous security issue when validating string input from
|
||||
@@ -35,7 +35,7 @@ Basic usage is to provide an array during instantiation:
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\InArray([
|
||||
'haystack' => ['value1', 'value2',...'valueN']
|
||||
'haystack' => ['value1', 'value2',...'valueN'],
|
||||
]);
|
||||
|
||||
if ($validator->isValid('value')) {
|
||||
@@ -83,7 +83,7 @@ It's possible to set the strict mode at initialisation and afterwards with the
|
||||
```php
|
||||
// defaults to InArray::COMPARE_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY
|
||||
$validator = new Zend\Validator\InArray([
|
||||
'haystack' => array('value1', 'value2', /* ... */ 'valueN'),
|
||||
'haystack' => ['value1', 'value2', /* ... */ 'valueN'],
|
||||
]);
|
||||
|
||||
// set strict mode
|
||||
@@ -118,7 +118,7 @@ To validate multidimensional arrays you have to set the `recursive` option.
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\InArray([
|
||||
'haystack' => array(
|
||||
'haystack' => [
|
||||
'firstDimension' => ['value1', 'value2', / ... */ 'valueN'],
|
||||
'secondDimension' => ['foo1', 'foo2', /* ... */ 'fooN'],
|
||||
],
|
||||
|
107
vendor/zendframework/zend-validator/doc/book/validators/is-countable.md
vendored
Normal file
107
vendor/zendframework/zend-validator/doc/book/validators/is-countable.md
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
# IsCountable Validator
|
||||
|
||||
- **Since 2.10.0**
|
||||
|
||||
`Zend\Validator\IsCountable` allows you to validate that a value can be counted
|
||||
(i.e., it's an array or implements `Countable`), and, optionally:
|
||||
|
||||
- the exact count of the value
|
||||
- the minimum count of the value
|
||||
- the maximum count of the value
|
||||
|
||||
Specifying either of the latter two is inconsistent with the first, and, as
|
||||
such, the validator does not allow setting both a count and a minimum or maximum
|
||||
value. You may, however specify both minimum and maximum values, in which case
|
||||
the validator operates similar to the [Between validator](between.md).
|
||||
|
||||
## Supported options
|
||||
|
||||
The following options are supported for `Zend\Validator\IsCountable`:
|
||||
|
||||
- `count`: Defines if the validation should look for a specific, exact count for
|
||||
the value provided.
|
||||
- `max`: Sets the maximum value for the validation; if the count of the value is
|
||||
greater than the maximum, validation fails..
|
||||
- `min`: Sets the minimum value for the validation; if the count of the value is
|
||||
lower than the minimum, validation fails.
|
||||
|
||||
## Default behaviour
|
||||
|
||||
Given no options, the validator simply tests to see that the value may be
|
||||
counted (i.e., it's an array or `Countable` instance):
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\IsCountable();
|
||||
|
||||
$validator->isValid(10); // false; not an array or Countable
|
||||
$validator->isValid([10]); // true; value is an array
|
||||
$validator->isValid(new ArrayObject([10])); // true; value is Countable
|
||||
$validator->isValid(new stdClass); // false; value is not Countable
|
||||
```
|
||||
|
||||
## Specifying an exact count
|
||||
|
||||
You can also specify an exact count; if the value is countable, and its count
|
||||
matches, the the value is valid.
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\IsCountable(['count' => 3]);
|
||||
|
||||
$validator->isValid([1, 2, 3]); // true; countable, and count is 3
|
||||
$validator->isValid(new ArrayObject([1, 2, 3])); // true; countable, and count is 3
|
||||
$validator->isValid([1]); // false; countable, but count is 1
|
||||
$validator->isValid(new ArrayObject([1])); // false; countable, but count is 1
|
||||
```
|
||||
|
||||
## Specifying a minimum count
|
||||
|
||||
You may specify a minimum count. When you do, the value must be countable, and
|
||||
greater than or equal to the minimum count you specify in order to be valid.
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\IsCountable(['min' => 2]);
|
||||
|
||||
$validator->isValid([1, 2, 3]); // true; countable, and count is 3
|
||||
$validator->isValid(new ArrayObject([1, 2, 3])); // true; countable, and count is 3
|
||||
$validator->isValid([1, 2]); // true; countable, and count is 2
|
||||
$validator->isValid(new ArrayObject([1, 2])); // true; countable, and count is 2
|
||||
$validator->isValid([1]); // false; countable, but count is 1
|
||||
$validator->isValid(new ArrayObject([1])); // false; countable, but count is 1
|
||||
```
|
||||
|
||||
## Specifying a maximum count
|
||||
|
||||
You may specify a maximum count. When you do, the value must be countable, and
|
||||
less than or equal to the maximum count you specify in order to be valid.
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\IsCountable(['max' => 2]);
|
||||
|
||||
$validator->isValid([1, 2, 3]); // false; countable, but count is 3
|
||||
$validator->isValid(new ArrayObject([1, 2, 3])); // false; countable, but count is 3
|
||||
$validator->isValid([1, 2]); // true; countable, and count is 2
|
||||
$validator->isValid(new ArrayObject([1, 2])); // true; countable, and count is 2
|
||||
$validator->isValid([1]); // true; countable, and count is 1
|
||||
$validator->isValid(new ArrayObject([1])); // true; countable, and count is 1
|
||||
```
|
||||
|
||||
## Specifying both minimum and maximum
|
||||
|
||||
If you specify both a minimum and maximum, the count must be _between_ the two,
|
||||
inclusively (i.e., it may be the minimum or maximum, and any value between).
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\IsCountable([
|
||||
'min' => 3,
|
||||
'max' => 5,
|
||||
]);
|
||||
|
||||
$validator->isValid([1, 2, 3]); // true; countable, and count is 3
|
||||
$validator->isValid(new ArrayObject([1, 2, 3])); // true; countable, and count is 3
|
||||
$validator->isValid(range(1, 5)); // true; countable, and count is 5
|
||||
$validator->isValid(new ArrayObject(range(1, 5))); // true; countable, and count is 5
|
||||
$validator->isValid([1, 2]); // false; countable, and count is 2
|
||||
$validator->isValid(new ArrayObject([1, 2])); // false; countable, and count is 2
|
||||
$validator->isValid(range(1, 6)); // false; countable, and count is 6
|
||||
$validator->isValid(new ArrayObject(range(1, 6))); // false; countable, and count is 6
|
||||
```
|
@@ -67,7 +67,7 @@ use Zend\Validator\NotEmpty;
|
||||
$validator = new NotEmpty(NotEmpty::INTEGER);
|
||||
|
||||
// Returns false on 0 or '0'
|
||||
$validator = new NotEmpty( NotEmpty::INTEGER + NotEmpty::ZERO);
|
||||
$validator = new NotEmpty( NotEmpty::INTEGER | NotEmpty::ZERO);
|
||||
|
||||
// Returns false on 0 or '0'
|
||||
$validator = new NotEmpty([ NotEmpty::INTEGER, NotEmpty::ZERO ]);
|
||||
|
@@ -1,90 +0,0 @@
|
||||
# PostCode Validator
|
||||
|
||||
`Zend\I18n\Validator\PostCode` allows you to determine if a given value is a
|
||||
valid postal code. Postal codes are specific to cities, and in some locales
|
||||
termed ZIP codes.
|
||||
|
||||
`Zend\I18n\Validator\PostCode` knows more than 160 different postal code
|
||||
formats. To select the correct format there are two ways. You can either use a
|
||||
fully qualified locale, or you can set your own format manually.
|
||||
|
||||
## Supported options
|
||||
|
||||
The following options are supported for `Zend\I18n\Validator\PostCode`:
|
||||
|
||||
- `format`: Sets a postcode format which will be used for validation of the
|
||||
input.
|
||||
- `locale`: Sets a locale from which the postcode will be taken from.
|
||||
|
||||
## Usage
|
||||
|
||||
Using a locale is more convenient as zend-validator already knows the
|
||||
appropriate postal code format for each locale; however, you need to use the
|
||||
fully qualified locale (one containing a region specifier) to do so. For
|
||||
instance, the locale `de` is a locale but could not be used with
|
||||
`Zend\I18n\Validator\PostCode` as it does not include the region; `de_AT`,
|
||||
however, would be a valid locale, as it specifies the region code (`AT`, for
|
||||
Austria).
|
||||
|
||||
```php
|
||||
$validator = new Zend\I18n\Validator\PostCode('de_AT');
|
||||
```
|
||||
|
||||
When you don't set a locale yourself, then `Zend\I18n\Validator\PostCode` will
|
||||
use the application wide set locale, or, when there is none, the locale returned
|
||||
by `Locale`.
|
||||
|
||||
```php
|
||||
// application wide locale within your bootstrap
|
||||
Locale::setDefault('de_AT');
|
||||
|
||||
$validator = new Zend\I18n\Validator\PostCode();
|
||||
```
|
||||
|
||||
You can also change the locale afterwards by calling `setLocale()`. And of
|
||||
course you can get the actual used locale by calling `getLocale()`.
|
||||
|
||||
```php
|
||||
$validator = new Zend\I18n\Validator\PostCode('de_AT');
|
||||
$validator->setLocale('en_GB');
|
||||
```
|
||||
|
||||
Postal code formats are regular expression strings. When the international
|
||||
postal code format, which is used by setting the locale, does not fit your
|
||||
needs, then you can also manually set a format by calling `setFormat()`.
|
||||
|
||||
```php
|
||||
$validator = new Zend\I18n\Validator\PostCode('de_AT');
|
||||
$validator->setFormat('AT-\d{5}');
|
||||
```
|
||||
|
||||
> ### Conventions for self defined formats
|
||||
>
|
||||
> When using self defined formats, you should omit the regex delimiters and
|
||||
> anchors (`'/^'` and `'$/'`). They are attached automatically.
|
||||
>
|
||||
> You should also be aware that postcode values are always be validated in a
|
||||
> strict way. This means that they have to be written standalone without
|
||||
> additional characters when they are not covered by the format.
|
||||
|
||||
## Constructor options
|
||||
|
||||
At its most basic, you may pass a string representing a fully qualified locale
|
||||
to the constructor of `Zend\I18n\Validator\PostCode`.
|
||||
|
||||
```php
|
||||
$validator = new Zend\I18n\Validator\PostCode('de_AT');
|
||||
$validator = new Zend\I18n\Validator\PostCode($locale);
|
||||
```
|
||||
|
||||
Additionally, you may pass either an array or a `Traversable` instance to the
|
||||
constructor. When you do so, you must include either the key `locale` or
|
||||
`format`; these will be used to set the appropriate values in the validator
|
||||
object.
|
||||
|
||||
```php
|
||||
$validator = new Zend\I18n\Validator\PostCode([
|
||||
'locale' => 'de_AT',
|
||||
'format' => 'AT_\d+'
|
||||
]);
|
||||
```
|
@@ -15,11 +15,12 @@ The following options are supported for `Zend\Validator\StringLength`:
|
||||
- `encoding`: Sets the `ICONV` encoding to use with the string.
|
||||
- `min`: Sets the minimum allowed length for a string.
|
||||
- `max`: Sets the maximum allowed length for a string.
|
||||
- `length`: Holds the actual length of the string.
|
||||
|
||||
## Default behaviour
|
||||
|
||||
By default, this validator checks if a value is between `min` and `max` using a
|
||||
default`min` value of `0` and default `max` value of `NULL` (meaning unlimited).
|
||||
default `min` value of `0` and default `max` value of `NULL` (meaning unlimited).
|
||||
|
||||
As such, without any options, the validator only checks that the input is a
|
||||
string.
|
||||
@@ -116,3 +117,11 @@ $validator2->isValid("Ärger"); // returns true
|
||||
|
||||
When your installation and your application are using different encodings, then
|
||||
you should always set an encoding manually.
|
||||
|
||||
## Validation Messages
|
||||
Using the setMessage() method you can set another message to be returned in case of the specified failure.
|
||||
|
||||
```php
|
||||
$validator = new Zend\Validator\StringLength(['min' => 3, 'max' => 30]);
|
||||
$validator->setMessage('Youre string is too long. You typed '%length%' chars.', Zend\Validator\StringLength::TOO_LONG);
|
||||
```
|
||||
|
@@ -76,7 +76,7 @@ message template.
|
||||
The following example demonstrates a more complex set of validation rules:
|
||||
|
||||
- The input must be numeric.
|
||||
- The input must fall within a range of bouncary values.
|
||||
- The input must fall within a range of boundary values.
|
||||
|
||||
An input value would fail validation for exactly one of the following reasons:
|
||||
|
||||
|
@@ -17,6 +17,7 @@ pages:
|
||||
- "Db\\RecordExists and Db\\NoRecordExists": validators/db.md
|
||||
- Digits: validators/digits.md
|
||||
- EmailAddress: validators/email-address.md
|
||||
- Explode: validators/explode.md
|
||||
- GreaterThan: validators/greater-than.md
|
||||
- Hex: validators/hex.md
|
||||
- Hostname: validators/hostname.md
|
||||
@@ -25,10 +26,10 @@ pages:
|
||||
- InArray: validators/in-array.md
|
||||
- Ip: validators/ip.md
|
||||
- Isbn: validators/isbn.md
|
||||
- IsCountable: validators/is-countable.md
|
||||
- IsInstanceOf: validators/isinstanceof.md
|
||||
- LessThan: validators/less-than.md
|
||||
- NotEmpty: validators/not-empty.md
|
||||
- PostCode: validators/post-code.md
|
||||
- Regex: validators/regex.md
|
||||
- Sitemap: validators/sitemap.md
|
||||
- Step: validators/step.md
|
||||
|
8
vendor/zendframework/zend-validator/phpcs.xml
vendored
Normal file
8
vendor/zendframework/zend-validator/phpcs.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Zend Framework coding standard">
|
||||
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>
|
||||
|
||||
<!-- Paths to check -->
|
||||
<file>src</file>
|
||||
<file>test</file>
|
||||
</ruleset>
|
@@ -126,7 +126,7 @@ abstract class AbstractValidator implements
|
||||
*/
|
||||
public function setOptions($options = [])
|
||||
{
|
||||
if (!is_array($options) && !$options instanceof Traversable) {
|
||||
if (! is_array($options) && ! $options instanceof Traversable) {
|
||||
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable');
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ abstract class AbstractValidator implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!isset($this->abstractOptions['messageTemplates'][$messageKey])) {
|
||||
if (! isset($this->abstractOptions['messageTemplates'][$messageKey])) {
|
||||
throw new Exception\InvalidArgumentException("No message template exists for key '$messageKey'");
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ abstract class AbstractValidator implements
|
||||
*/
|
||||
protected function createMessage($messageKey, $value)
|
||||
{
|
||||
if (!isset($this->abstractOptions['messageTemplates'][$messageKey])) {
|
||||
if (! isset($this->abstractOptions['messageTemplates'][$messageKey])) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ abstract class AbstractValidator implements
|
||||
$message = $this->translateMessage($messageKey, $message);
|
||||
|
||||
if (is_object($value) &&
|
||||
!in_array('__toString', get_class_methods($value))
|
||||
! in_array('__toString', get_class_methods($value))
|
||||
) {
|
||||
$value = get_class($value) . ' object';
|
||||
} elseif (is_array($value)) {
|
||||
@@ -565,7 +565,7 @@ abstract class AbstractValidator implements
|
||||
protected function translateMessage($messageKey, $message)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
if (!$translator) {
|
||||
if (! $translator) {
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ class Barcode extends AbstractValidator
|
||||
$options = [];
|
||||
}
|
||||
|
||||
if (!is_array($options) && !($options instanceof Traversable)) {
|
||||
if (! is_array($options) && ! ($options instanceof Traversable)) {
|
||||
$options = ['adapter' => $options];
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class Barcode extends AbstractValidator
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
if (!($this->options['adapter'] instanceof Barcode\AdapterInterface)) {
|
||||
if (! ($this->options['adapter'] instanceof Barcode\AdapterInterface)) {
|
||||
$this->setAdapter('Ean13');
|
||||
}
|
||||
|
||||
@@ -91,14 +91,14 @@ class Barcode extends AbstractValidator
|
||||
$adapter = ucfirst(strtolower($adapter));
|
||||
$adapter = 'Zend\\Validator\\Barcode\\' . $adapter;
|
||||
|
||||
if (!class_exists($adapter)) {
|
||||
if (! class_exists($adapter)) {
|
||||
throw new Exception\InvalidArgumentException('Barcode adapter matching "' . $adapter . '" not found');
|
||||
}
|
||||
|
||||
$adapter = new $adapter($options);
|
||||
}
|
||||
|
||||
if (!$adapter instanceof Barcode\AdapterInterface) {
|
||||
if (! $adapter instanceof Barcode\AdapterInterface) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
sprintf(
|
||||
"Adapter %s does not implement Zend\\Validator\\Barcode\\AdapterInterface",
|
||||
@@ -143,7 +143,7 @@ class Barcode extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class Barcode extends AbstractValidator
|
||||
$adapter = $this->getAdapter();
|
||||
$this->options['length'] = $adapter->getLength();
|
||||
$result = $adapter->hasValidLength($value);
|
||||
if (!$result) {
|
||||
if (! $result) {
|
||||
if (is_array($this->options['length'])) {
|
||||
$temp = $this->options['length'];
|
||||
$this->options['length'] = "";
|
||||
@@ -169,14 +169,14 @@ class Barcode extends AbstractValidator
|
||||
}
|
||||
|
||||
$result = $adapter->hasValidCharacters($value);
|
||||
if (!$result) {
|
||||
if (! $result) {
|
||||
$this->error(self::INVALID_CHARS);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->useChecksum(null)) {
|
||||
$result = $adapter->hasValidChecksum($value);
|
||||
if (!$result) {
|
||||
if (! $result) {
|
||||
$this->error(self::FAILED);
|
||||
return false;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ abstract class AbstractAdapter implements AdapterInterface
|
||||
*/
|
||||
public function hasValidLength($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ abstract class AbstractAdapter implements AdapterInterface
|
||||
*/
|
||||
public function hasValidCharacters($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ abstract class AbstractAdapter implements AdapterInterface
|
||||
public function hasValidChecksum($value)
|
||||
{
|
||||
$checksum = $this->getChecksum();
|
||||
if (!empty($checksum)) {
|
||||
if (! empty($checksum)) {
|
||||
if (method_exists($this, $checksum)) {
|
||||
return $this->$checksum($value);
|
||||
}
|
||||
|
@@ -29,13 +29,13 @@ class Codabar extends AbstractAdapter
|
||||
{
|
||||
if (strpbrk($value, 'ABCD')) {
|
||||
$first = $value[0];
|
||||
if (!strpbrk($first, 'ABCD')) {
|
||||
if (! strpbrk($first, 'ABCD')) {
|
||||
// Missing start char
|
||||
return false;
|
||||
}
|
||||
|
||||
$last = substr($value, -1, 1);
|
||||
if (!strpbrk($last, 'ABCD')) {
|
||||
if (! strpbrk($last, 'ABCD')) {
|
||||
// Missing stop char
|
||||
return false;
|
||||
}
|
||||
@@ -43,13 +43,13 @@ class Codabar extends AbstractAdapter
|
||||
$value = substr($value, 1, -1);
|
||||
} elseif (strpbrk($value, 'TN*E')) {
|
||||
$first = $value[0];
|
||||
if (!strpbrk($first, 'TN*E')) {
|
||||
if (! strpbrk($first, 'TN*E')) {
|
||||
// Missing start char
|
||||
return false;
|
||||
}
|
||||
|
||||
$last = substr($value, -1, 1);
|
||||
if (!strpbrk($last, 'TN*E')) {
|
||||
if (! strpbrk($last, 'TN*E')) {
|
||||
// Missing stop char
|
||||
return false;
|
||||
}
|
||||
|
@@ -38,10 +38,10 @@ class Code128 extends AbstractAdapter
|
||||
40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O',
|
||||
48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W',
|
||||
56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\', 61 => ']', 62 => '^', 63 => '_',
|
||||
64 =>0x00, 65 =>0x01, 66 =>0x02, 67 =>0x03, 68 =>0x04, 69 =>0x05, 70 =>0x06, 71 =>0x07,
|
||||
72 =>0x08, 73 =>0x09, 74 =>0x0A, 75 =>0x0B, 76 =>0x0C, 77 =>0x0D, 78 =>0x0E, 79 =>0x0F,
|
||||
80 =>0x10, 81 =>0x11, 82 =>0x12, 83 =>0x13, 84 =>0x14, 85 =>0x15, 86 =>0x16, 87 =>0x17,
|
||||
88 =>0x18, 89 =>0x19, 90 =>0x1A, 91 =>0x1B, 92 =>0x1C, 93 =>0x1D, 94 =>0x1E, 95 =>0x1F,
|
||||
64 => 0x00, 65 => 0x01, 66 => 0x02, 67 => 0x03, 68 => 0x04, 69 => 0x05, 70 => 0x06, 71 => 0x07,
|
||||
72 => 0x08, 73 => 0x09, 74 => 0x0A, 75 => 0x0B, 76 => 0x0C, 77 => 0x0D, 78 => 0x0E, 79 => 0x0F,
|
||||
80 => 0x10, 81 => 0x11, 82 => 0x12, 83 => 0x13, 84 => 0x14, 85 => 0x15, 86 => 0x16, 87 => 0x17,
|
||||
88 => 0x18, 89 => 0x19, 90 => 0x1A, 91 => 0x1B, 92 => 0x1C, 93 => 0x1D, 94 => 0x1E, 95 => 0x1F,
|
||||
96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â', 100 => 'ä', 101 => 'à', 102 => 'å', 103 => '‡',
|
||||
104 => 'ˆ', 105 => '‰', 106 => 'Š'],
|
||||
'B' => [
|
||||
@@ -56,7 +56,7 @@ class Code128 extends AbstractAdapter
|
||||
64 => '`', 65 => 'a', 66 => 'b', 67 => 'c', 68 => 'd', 69 => 'e', 70 => 'f', 71 => 'g',
|
||||
72 => 'h', 73 => 'i', 74 => 'j', 75 => 'k', 76 => 'l', 77 => 'm', 78 => 'n', 79 => 'o',
|
||||
80 => 'p', 81 => 'q', 82 => 'r', 83 => 's', 84 => 't', 85 => 'u', 86 => 'v', 87 => 'w',
|
||||
88 => 'x', 89 => 'y', 90 => 'z', 91 => '{', 92 => '|', 93 => '}', 94 => '~', 95 =>0x7F,
|
||||
88 => 'x', 89 => 'y', 90 => 'z', 91 => '{', 92 => '|', 93 => '}', 94 => '~', 95 => 0x7F,
|
||||
96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â', 100 => 'ä', 101 => 'à', 102 => 'å', 103 => '‡',
|
||||
104 => 'ˆ', 105 => '‰', 106 => 'Š'],
|
||||
'C' => [
|
||||
@@ -80,7 +80,7 @@ class Code128 extends AbstractAdapter
|
||||
|
||||
public function setUtf8StringWrapper(StringWrapperInterface $utf8StringWrapper)
|
||||
{
|
||||
if (!$utf8StringWrapper->isSupported('UTF-8')) {
|
||||
if (! $utf8StringWrapper->isSupported('UTF-8')) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
"The string wrapper needs to support UTF-8 character encoding"
|
||||
);
|
||||
@@ -95,7 +95,7 @@ class Code128 extends AbstractAdapter
|
||||
*/
|
||||
public function getUtf8StringWrapper()
|
||||
{
|
||||
if (!$this->utf8StringWrapper) {
|
||||
if (! $this->utf8StringWrapper) {
|
||||
$this->utf8StringWrapper = StringUtils::getWrapper('UTF-8');
|
||||
}
|
||||
return $this->utf8StringWrapper;
|
||||
@@ -109,7 +109,7 @@ class Code128 extends AbstractAdapter
|
||||
*/
|
||||
public function hasValidCharacters($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ class Code128 extends AbstractAdapter
|
||||
|
||||
if (($strWrapper->strpos($value, 'Š') != 1) || ($strWrapper->strlen($value) != 2)) {
|
||||
// return false if checksum is not readable and true if no startvalue is detected
|
||||
return (!$usecheck);
|
||||
return (! $usecheck);
|
||||
}
|
||||
|
||||
$mod = $sum % 103;
|
||||
@@ -378,7 +378,7 @@ class Code128 extends AbstractAdapter
|
||||
}
|
||||
} else {
|
||||
if ($ord < 32) {
|
||||
return ($ord +64);
|
||||
return ($ord + 64);
|
||||
} elseif ($ord <= 138) {
|
||||
return ($ord - 32);
|
||||
} else {
|
||||
|
@@ -15,8 +15,8 @@ class Code39 extends AbstractAdapter
|
||||
* @var array
|
||||
*/
|
||||
protected $check = [
|
||||
'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
|
||||
'7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13,
|
||||
'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
|
||||
'7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13,
|
||||
'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20,
|
||||
'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27,
|
||||
'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34,
|
||||
|
@@ -16,8 +16,8 @@ class Code93 extends AbstractAdapter
|
||||
* @var array
|
||||
*/
|
||||
protected $check = [
|
||||
'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
|
||||
'7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13,
|
||||
'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
|
||||
'7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13,
|
||||
'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20,
|
||||
'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27,
|
||||
'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34,
|
||||
|
@@ -16,6 +16,15 @@ class Between extends AbstractValidator
|
||||
{
|
||||
const NOT_BETWEEN = 'notBetween';
|
||||
const NOT_BETWEEN_STRICT = 'notBetweenStrict';
|
||||
const VALUE_NOT_NUMERIC = 'valueNotNumeric';
|
||||
const VALUE_NOT_STRING = 'valueNotString';
|
||||
|
||||
/**
|
||||
* Retain if min and max are numeric values. Allow to not compare string and numeric types
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $numeric;
|
||||
|
||||
/**
|
||||
* Validation failure message template definitions
|
||||
@@ -24,7 +33,10 @@ class Between extends AbstractValidator
|
||||
*/
|
||||
protected $messageTemplates = [
|
||||
self::NOT_BETWEEN => "The input is not between '%min%' and '%max%', inclusively",
|
||||
self::NOT_BETWEEN_STRICT => "The input is not strictly between '%min%' and '%max%'"
|
||||
self::NOT_BETWEEN_STRICT => "The input is not strictly between '%min%' and '%max%'",
|
||||
self::VALUE_NOT_NUMERIC => "The min ('%min%') and max ('%max%') values are numeric, but the input is not",
|
||||
self::VALUE_NOT_STRING => "The min ('%min%') and max ('%max%') values are non-numeric strings, "
|
||||
. "but the input is not a string",
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -64,24 +76,36 @@ class Between extends AbstractValidator
|
||||
if ($options instanceof Traversable) {
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['min'] = array_shift($options);
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['max'] = array_shift($options);
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['inclusive'] = array_shift($options);
|
||||
}
|
||||
|
||||
$options = $temp;
|
||||
}
|
||||
|
||||
if (count($options) !== 2
|
||||
&& (!array_key_exists('min', $options) || !array_key_exists('max', $options))
|
||||
if (! array_key_exists('min', $options) || ! array_key_exists('max', $options)) {
|
||||
throw new Exception\InvalidArgumentException("Missing option: 'min' and 'max' have to be given");
|
||||
}
|
||||
|
||||
if ((isset($options['min']) && is_numeric($options['min']))
|
||||
&& (isset($options['max']) && is_numeric($options['max']))
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException("Missing option. 'min' and 'max' have to be given");
|
||||
$this->numeric = true;
|
||||
} elseif ((isset($options['min']) && is_string($options['min']))
|
||||
&& (isset($options['max']) && is_string($options['max']))
|
||||
) {
|
||||
$this->numeric = false;
|
||||
} else {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
"Invalid options: 'min' and 'max' should be of the same scalar type"
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($options);
|
||||
@@ -164,6 +188,15 @@ class Between extends AbstractValidator
|
||||
{
|
||||
$this->setValue($value);
|
||||
|
||||
if ($this->numeric && ! is_numeric($value)) {
|
||||
$this->error(self::VALUE_NOT_NUMERIC);
|
||||
return false;
|
||||
}
|
||||
if (! $this->numeric && ! is_string($value)) {
|
||||
$this->error(self::VALUE_NOT_STRING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->getInclusive()) {
|
||||
if ($this->getMin() > $value || $value > $this->getMax()) {
|
||||
$this->error(self::NOT_BETWEEN);
|
||||
|
@@ -70,16 +70,16 @@ class Bitwise extends AbstractValidator
|
||||
$options = iterator_to_array($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
|
||||
$temp['control'] = array_shift($options);
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['operator'] = array_shift($options);
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['strict'] = array_shift($options);
|
||||
}
|
||||
|
||||
|
@@ -74,7 +74,7 @@ class Callback extends AbstractValidator
|
||||
*/
|
||||
public function setCallback($callback)
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
if (! is_callable($callback)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid callback given');
|
||||
}
|
||||
|
||||
@@ -124,19 +124,19 @@ class Callback extends AbstractValidator
|
||||
}
|
||||
|
||||
$args = [$value];
|
||||
if (empty($options) && !empty($context)) {
|
||||
if (empty($options) && ! empty($context)) {
|
||||
$args[] = $context;
|
||||
}
|
||||
if (!empty($options) && empty($context)) {
|
||||
if (! empty($options) && empty($context)) {
|
||||
$args = array_merge($args, $options);
|
||||
}
|
||||
if (!empty($options) && !empty($context)) {
|
||||
if (! empty($options) && ! empty($context)) {
|
||||
$args[] = $context;
|
||||
$args = array_merge($args, $options);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!call_user_func_array($callback, $args)) {
|
||||
if (! call_user_func_array($callback, $args)) {
|
||||
$this->error(self::INVALID_VALUE);
|
||||
return false;
|
||||
}
|
||||
|
@@ -29,8 +29,11 @@ class ConfigProvider
|
||||
public function getDependencyConfig()
|
||||
{
|
||||
return [
|
||||
'aliases' => [
|
||||
'ValidatorManager' => ValidatorPluginManager::class,
|
||||
],
|
||||
'factories' => [
|
||||
'ValidatorManager' => ValidatorPluginManagerFactory::class,
|
||||
ValidatorPluginManager::class => ValidatorPluginManagerFactory::class,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ class CreditCard extends AbstractValidator
|
||||
const MASTERCARD = 'Mastercard';
|
||||
const SOLO = 'Solo';
|
||||
const VISA = 'Visa';
|
||||
const MIR = 'Mir';
|
||||
|
||||
const CHECKSUM = 'creditcardChecksum';
|
||||
const CONTENT = 'creditcardContent';
|
||||
@@ -72,6 +73,7 @@ class CreditCard extends AbstractValidator
|
||||
8 => self::SOLO,
|
||||
9 => self::UNIONPAY,
|
||||
10 => self::VISA,
|
||||
11 => self::MIR,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -83,14 +85,15 @@ class CreditCard extends AbstractValidator
|
||||
self::AMERICAN_EXPRESS => [15],
|
||||
self::DINERS_CLUB => [14],
|
||||
self::DINERS_CLUB_US => [16],
|
||||
self::DISCOVER => [16],
|
||||
self::DISCOVER => [16, 19],
|
||||
self::JCB => [15, 16],
|
||||
self::LASER => [16, 17, 18, 19],
|
||||
self::MAESTRO => [12, 13, 14, 15, 16, 17, 18, 19],
|
||||
self::MASTERCARD => [16],
|
||||
self::SOLO => [16, 18, 19],
|
||||
self::UNIONPAY => [16, 17, 18, 19],
|
||||
self::VISA => [16],
|
||||
self::VISA => [13, 16, 19],
|
||||
self::MIR => [13, 16],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -112,13 +115,17 @@ class CreditCard extends AbstractValidator
|
||||
self::LASER => ['6304', '6706', '6771', '6709'],
|
||||
self::MAESTRO => ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763',
|
||||
'6764', '6765', '6766', '6772'],
|
||||
self::MASTERCARD => ['51', '52', '53', '54', '55'],
|
||||
self::MASTERCARD => ['2221', '2222', '2223', '2224', '2225', '2226', '2227', '2228', '2229',
|
||||
'223', '224', '225', '226', '227', '228', '229',
|
||||
'23', '24', '25', '26', '271', '2720',
|
||||
'51', '52', '53', '54', '55'],
|
||||
self::SOLO => ['6334', '6767'],
|
||||
self::UNIONPAY => ['622126', '622127', '622128', '622129', '62213', '62214',
|
||||
'62215', '62216', '62217', '62218', '62219', '6222', '6223',
|
||||
'6224', '6225', '6226', '6227', '6228', '62290', '62291',
|
||||
'622920', '622921', '622922', '622923', '622924', '622925'],
|
||||
self::VISA => ['4'],
|
||||
self::MIR => ['2200', '2201', '2202', '2203', '2204'],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -140,17 +147,17 @@ class CreditCard extends AbstractValidator
|
||||
{
|
||||
if ($options instanceof Traversable) {
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
} elseif (!is_array($options)) {
|
||||
} elseif (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['type'] = array_shift($options);
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['service'] = array_shift($options);
|
||||
}
|
||||
|
||||
$options = $temp;
|
||||
}
|
||||
|
||||
if (!array_key_exists('type', $options)) {
|
||||
if (! array_key_exists('type', $options)) {
|
||||
$options['type'] = self::ALL;
|
||||
}
|
||||
|
||||
@@ -200,13 +207,20 @@ class CreditCard extends AbstractValidator
|
||||
}
|
||||
|
||||
foreach ($type as $typ) {
|
||||
if (defined('self::' . strtoupper($typ)) && !in_array($typ, $this->options['type'])) {
|
||||
$this->options['type'][] = $typ;
|
||||
}
|
||||
|
||||
if (($typ == self::ALL)) {
|
||||
$this->options['type'] = array_keys($this->cardLength);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($typ, $this->options['type'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$constant = 'static::' . strtoupper($typ);
|
||||
if (! defined($constant) || in_array(constant($constant), $this->options['type'])) {
|
||||
continue;
|
||||
}
|
||||
$this->options['type'][] = constant($constant);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -231,7 +245,7 @@ class CreditCard extends AbstractValidator
|
||||
*/
|
||||
public function setService($service)
|
||||
{
|
||||
if (!is_callable($service)) {
|
||||
if (! is_callable($service)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid callback given');
|
||||
}
|
||||
|
||||
@@ -249,12 +263,12 @@ class CreditCard extends AbstractValidator
|
||||
{
|
||||
$this->setValue($value);
|
||||
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID, $value);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ctype_digit($value)) {
|
||||
if (! ctype_digit($value)) {
|
||||
$this->error(self::CONTENT, $value);
|
||||
return false;
|
||||
}
|
||||
@@ -300,11 +314,11 @@ class CreditCard extends AbstractValidator
|
||||
}
|
||||
|
||||
$service = $this->getService();
|
||||
if (!empty($service)) {
|
||||
if (! empty($service)) {
|
||||
try {
|
||||
$callback = new Callback($service);
|
||||
$callback->setOptions($this->getType());
|
||||
if (!$callback->isValid($value)) {
|
||||
if (! $callback->isValid($value)) {
|
||||
$this->error(self::SERVICE, $value);
|
||||
return false;
|
||||
}
|
||||
|
10
vendor/zendframework/zend-validator/src/Csrf.php
vendored
10
vendor/zendframework/zend-validator/src/Csrf.php
vendored
@@ -82,7 +82,7 @@ class Csrf extends AbstractValidator
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = (array) $options;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,11 @@ class Csrf extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value, $context = null)
|
||||
{
|
||||
$this->setValue((string) $value);
|
||||
if (! is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setValue($value);
|
||||
|
||||
$tokenId = $this->getTokenIdFromHash($value);
|
||||
$hash = $this->getValidationToken($tokenId);
|
||||
@@ -124,7 +128,7 @@ class Csrf extends AbstractValidator
|
||||
$tokenFromValue = $this->getTokenFromHash($value);
|
||||
$tokenFromHash = $this->getTokenFromHash($hash);
|
||||
|
||||
if (!$tokenFromValue || !$tokenFromHash || ($tokenFromValue !== $tokenFromHash)) {
|
||||
if (! $tokenFromValue || ! $tokenFromHash || ($tokenFromValue !== $tokenFromHash)) {
|
||||
$this->error(self::NOT_SAME);
|
||||
return false;
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ class Date extends AbstractValidator
|
||||
{
|
||||
if ($options instanceof Traversable) {
|
||||
$options = iterator_to_array($options);
|
||||
} elseif (!is_array($options)) {
|
||||
} elseif (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['format'] = array_shift($options);
|
||||
$options = $temp;
|
||||
@@ -110,7 +110,7 @@ class Date extends AbstractValidator
|
||||
{
|
||||
$this->setValue($value);
|
||||
|
||||
if (!$this->convertToDateTime($value)) {
|
||||
if (! $this->convertToDateTime($value)) {
|
||||
$this->error(self::INVALID_DATE);
|
||||
return false;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class Date extends AbstractValidator
|
||||
}
|
||||
|
||||
$type = gettype($param);
|
||||
if (!in_array($type, ['string', 'integer', 'double', 'array'])) {
|
||||
if (! in_array($type, ['string', 'integer', 'double', 'array'])) {
|
||||
if ($addErrors) {
|
||||
$this->error(self::INVALID);
|
||||
}
|
||||
|
@@ -63,26 +63,26 @@ class DateStep extends Date
|
||||
{
|
||||
if ($options instanceof Traversable) {
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
} elseif (!is_array($options)) {
|
||||
} elseif (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['baseValue'] = array_shift($options);
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['step'] = array_shift($options);
|
||||
}
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['format'] = array_shift($options);
|
||||
}
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['timezone'] = array_shift($options);
|
||||
}
|
||||
|
||||
$options = $temp;
|
||||
}
|
||||
|
||||
if (!isset($options['step'])) {
|
||||
if (! isset($options['step'])) {
|
||||
$options['step'] = new DateInterval('P1D');
|
||||
}
|
||||
if (!isset($options['timezone'])) {
|
||||
if (! isset($options['timezone'])) {
|
||||
$options['timezone'] = new DateTimeZone(date_default_timezone_get());
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ class DateStep extends Date
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!parent::isValid($value)) {
|
||||
if (! parent::isValid($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -107,22 +107,22 @@ abstract class AbstractDb extends AbstractValidator implements AdapterAwareInter
|
||||
|
||||
$temp['field'] = array_shift($options);
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['exclude'] = array_shift($options);
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['adapter'] = array_shift($options);
|
||||
}
|
||||
|
||||
$options = $temp;
|
||||
}
|
||||
|
||||
if (!array_key_exists('table', $options) && !array_key_exists('schema', $options)) {
|
||||
if (! array_key_exists('table', $options) && ! array_key_exists('schema', $options)) {
|
||||
throw new Exception\InvalidArgumentException('Table or Schema option missing!');
|
||||
}
|
||||
|
||||
if (!array_key_exists('field', $options)) {
|
||||
if (! array_key_exists('field', $options)) {
|
||||
throw new Exception\InvalidArgumentException('Field option missing!');
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class RecordExists extends AbstractDb
|
||||
$this->setValue($value);
|
||||
|
||||
$result = $this->query($value);
|
||||
if (!$result) {
|
||||
if (! $result) {
|
||||
$valid = false;
|
||||
$this->error(self::ERROR_NO_RECORD_FOUND);
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ class Digits extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value) && !is_int($value) && !is_float($value)) {
|
||||
if (! is_string($value) && ! is_int($value) && ! is_float($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
@@ -9,6 +9,8 @@
|
||||
|
||||
namespace Zend\Validator;
|
||||
|
||||
use UConverter;
|
||||
|
||||
class EmailAddress extends AbstractValidator
|
||||
{
|
||||
const INVALID = 'emailAddressInvalid';
|
||||
@@ -89,14 +91,14 @@ class EmailAddress extends AbstractValidator
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['allow'] = array_shift($options);
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['useMxCheck'] = array_shift($options);
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['hostnameValidator'] = array_shift($options);
|
||||
}
|
||||
|
||||
@@ -122,7 +124,7 @@ class EmailAddress extends AbstractValidator
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!isset($this->messageTemplates[$messageKey])) {
|
||||
if (! isset($this->messageTemplates[$messageKey])) {
|
||||
$this->getHostnameValidator()->setMessage($messageString, $messageKey);
|
||||
} else {
|
||||
parent::setMessage($messageString, $messageKey);
|
||||
@@ -140,7 +142,7 @@ class EmailAddress extends AbstractValidator
|
||||
*/
|
||||
public function getHostnameValidator()
|
||||
{
|
||||
if (!isset($this->options['hostnameValidator'])) {
|
||||
if (! isset($this->options['hostnameValidator'])) {
|
||||
$this->options['hostnameValidator'] = new Hostname($this->getAllow());
|
||||
}
|
||||
|
||||
@@ -291,7 +293,7 @@ class EmailAddress extends AbstractValidator
|
||||
*/
|
||||
protected function isReserved($host)
|
||||
{
|
||||
if (!preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $host)) {
|
||||
if (! preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $host)) {
|
||||
$host = gethostbynamel($host);
|
||||
} else {
|
||||
$host = [$host];
|
||||
@@ -340,7 +342,9 @@ class EmailAddress extends AbstractValidator
|
||||
// atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
|
||||
// "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
|
||||
$atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e';
|
||||
if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->idnToAscii($this->localPart))) {
|
||||
if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->localPart)) {
|
||||
$result = true;
|
||||
} elseif ($this->validateInternationalizedLocalPart($this->localPart)) {
|
||||
$result = true;
|
||||
} else {
|
||||
// Try quoted string format (RFC 5321 Chapter 4.1.2)
|
||||
@@ -360,6 +364,26 @@ class EmailAddress extends AbstractValidator
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $localPart Address local part to validate.
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateInternationalizedLocalPart($localPart)
|
||||
{
|
||||
if (extension_loaded('intl')
|
||||
&& false === UConverter::transcode($localPart, 'UTF-8', 'UTF-8')
|
||||
) {
|
||||
// invalid utf?
|
||||
return false;
|
||||
}
|
||||
|
||||
$atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e';
|
||||
// RFC 6532 extends atext to include non-ascii utf
|
||||
// @see https://tools.ietf.org/html/rfc6532#section-3.1
|
||||
$uatext = $atext . '\x{80}-\x{FFFF}';
|
||||
return (bool) preg_match('/^[' . $uatext . ']+(\x2e+[' . $uatext . ']+)*$/u', $localPart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the found MX Record information after validation including weight for further processing
|
||||
*
|
||||
@@ -379,8 +403,8 @@ class EmailAddress extends AbstractValidator
|
||||
{
|
||||
$mxHosts = [];
|
||||
$weight = [];
|
||||
$result = getmxrr($this->idnToAscii($this->hostname), $mxHosts, $weight);
|
||||
if (!empty($mxHosts) && !empty($weight)) {
|
||||
$result = getmxrr($this->hostname, $mxHosts, $weight);
|
||||
if (! empty($mxHosts) && ! empty($weight)) {
|
||||
$this->mxRecord = array_combine($mxHosts, $weight) ?: [];
|
||||
} else {
|
||||
$this->mxRecord = [];
|
||||
@@ -389,19 +413,19 @@ class EmailAddress extends AbstractValidator
|
||||
arsort($this->mxRecord);
|
||||
|
||||
// Fallback to IPv4 hosts if no MX record found (RFC 2821 SS 5).
|
||||
if (!$result) {
|
||||
if (! $result) {
|
||||
$result = gethostbynamel($this->hostname);
|
||||
if (is_array($result)) {
|
||||
$this->mxRecord = array_flip($result);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
if (! $result) {
|
||||
$this->error(self::INVALID_MX_RECORD);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!$this->options['useDeepMxCheck']) {
|
||||
if (! $this->options['useDeepMxCheck']) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -409,11 +433,11 @@ class EmailAddress extends AbstractValidator
|
||||
$reserved = true;
|
||||
foreach ($this->mxRecord as $hostname => $weight) {
|
||||
$res = $this->isReserved($hostname);
|
||||
if (!$res) {
|
||||
if (! $res) {
|
||||
$reserved = false;
|
||||
}
|
||||
|
||||
if (!$res
|
||||
if (! $res
|
||||
&& (checkdnsrr($hostname, "A")
|
||||
|| checkdnsrr($hostname, "AAAA")
|
||||
|| checkdnsrr($hostname, "A6"))
|
||||
@@ -423,7 +447,7 @@ class EmailAddress extends AbstractValidator
|
||||
}
|
||||
}
|
||||
|
||||
if (!$validAddress) {
|
||||
if (! $validAddress) {
|
||||
$result = false;
|
||||
$error = ($reserved) ? self::INVALID_SEGMENT : self::INVALID_MX_RECORD;
|
||||
$this->error($error);
|
||||
@@ -441,7 +465,7 @@ class EmailAddress extends AbstractValidator
|
||||
{
|
||||
$hostname = $this->getHostnameValidator()->setTranslator($this->getTranslator())
|
||||
->isValid($this->hostname);
|
||||
if (!$hostname) {
|
||||
if (! $hostname) {
|
||||
$this->error(self::INVALID_HOSTNAME);
|
||||
// Get messages and errors from hostnameValidator
|
||||
foreach ($this->getHostnameValidator()->getMessages() as $code => $message) {
|
||||
@@ -473,7 +497,7 @@ class EmailAddress extends AbstractValidator
|
||||
}
|
||||
|
||||
$this->localPart = $matches[1];
|
||||
$this->hostname = $matches[2];
|
||||
$this->hostname = $this->idnToAscii($matches[2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -491,16 +515,16 @@ class EmailAddress extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$length = true;
|
||||
$this->setValue($this->idnToUtf8($value));
|
||||
$this->setValue($value);
|
||||
|
||||
// Split email address up and disallow '..'
|
||||
if (!$this->splitEmailParts($this->getValue())) {
|
||||
if (! $this->splitEmailParts($this->getValue())) {
|
||||
$this->error(self::INVALID_FORMAT);
|
||||
return false;
|
||||
}
|
||||
@@ -511,6 +535,7 @@ class EmailAddress extends AbstractValidator
|
||||
}
|
||||
|
||||
// Match hostname part
|
||||
$hostname = false;
|
||||
if ($this->options['useDomainCheck']) {
|
||||
$hostname = $this->validateHostnamePart();
|
||||
}
|
||||
@@ -518,13 +543,7 @@ class EmailAddress extends AbstractValidator
|
||||
$local = $this->validateLocalPart();
|
||||
|
||||
// If both parts valid, return true
|
||||
if ($local && $length) {
|
||||
if (($this->options['useDomainCheck'] && $hostname) || !$this->options['useDomainCheck']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return ($local && $length) && (! $this->options['useDomainCheck'] || $hostname);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -535,6 +554,9 @@ class EmailAddress extends AbstractValidator
|
||||
protected function idnToAscii($email)
|
||||
{
|
||||
if (extension_loaded('intl')) {
|
||||
if (defined('INTL_IDNA_VARIANT_UTS46')) {
|
||||
return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email);
|
||||
}
|
||||
return (idn_to_ascii($email) ?: $email);
|
||||
}
|
||||
return $email;
|
||||
@@ -547,6 +569,10 @@ class EmailAddress extends AbstractValidator
|
||||
*/
|
||||
protected function idnToUtf8($email)
|
||||
{
|
||||
if (strlen($email) == 0) {
|
||||
return $email;
|
||||
}
|
||||
|
||||
if (extension_loaded('intl')) {
|
||||
// The documentation does not clarify what kind of failure
|
||||
// can happen in idn_to_utf8. One can assume if the source
|
||||
@@ -554,6 +580,9 @@ class EmailAddress extends AbstractValidator
|
||||
// the source string in those cases.
|
||||
// But not when the source string is long enough.
|
||||
// Thus we default to source string ourselves.
|
||||
if (defined('INTL_IDNA_VARIANT_UTS46')) {
|
||||
return idn_to_utf8($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email;
|
||||
}
|
||||
return idn_to_utf8($email) ?: $email;
|
||||
}
|
||||
return $email;
|
||||
|
@@ -85,7 +85,7 @@ class Explode extends AbstractValidator implements ValidatorPluginManagerAwareIn
|
||||
*/
|
||||
public function getValidatorPluginManager()
|
||||
{
|
||||
if (!$this->pluginManager) {
|
||||
if (! $this->pluginManager) {
|
||||
$this->setValidatorPluginManager(new ValidatorPluginManager(new ServiceManager));
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class Explode extends AbstractValidator implements ValidatorPluginManagerAwareIn
|
||||
public function setValidator($validator)
|
||||
{
|
||||
if (is_array($validator)) {
|
||||
if (!isset($validator['name'])) {
|
||||
if (! isset($validator['name'])) {
|
||||
throw new Exception\RuntimeException(
|
||||
'Invalid validator specification provided; does not include "name" key'
|
||||
);
|
||||
@@ -112,7 +112,7 @@ class Explode extends AbstractValidator implements ValidatorPluginManagerAwareIn
|
||||
$validator = $this->getValidatorPluginManager()->get($name, $options);
|
||||
}
|
||||
|
||||
if (!$validator instanceof ValidatorInterface) {
|
||||
if (! $validator instanceof ValidatorInterface) {
|
||||
throw new Exception\RuntimeException(
|
||||
'Invalid validator given'
|
||||
);
|
||||
@@ -189,7 +189,7 @@ class Explode extends AbstractValidator implements ValidatorPluginManagerAwareIn
|
||||
|
||||
$validator = $this->getValidator();
|
||||
|
||||
if (!$validator) {
|
||||
if (! $validator) {
|
||||
throw new Exception\RuntimeException(sprintf(
|
||||
'%s expects a validator to be set; none given',
|
||||
__METHOD__
|
||||
@@ -197,7 +197,7 @@ class Explode extends AbstractValidator implements ValidatorPluginManagerAwareIn
|
||||
}
|
||||
|
||||
foreach ($values as $value) {
|
||||
if (!$validator->isValid($value, $context)) {
|
||||
if (! $validator->isValid($value, $context)) {
|
||||
$this->abstractOptions['messages'][] = $validator->getMessages();
|
||||
|
||||
if ($this->isBreakOnFirstFailure()) {
|
||||
|
@@ -185,7 +185,7 @@ class Count extends AbstractValidator
|
||||
|
||||
if (is_array($file)) {
|
||||
foreach ($file as $name) {
|
||||
if (!isset($this->files[$name]) && !empty($name)) {
|
||||
if (! isset($this->files[$name]) && ! empty($name)) {
|
||||
$this->files[$name] = $name;
|
||||
}
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class Count extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value, $file = null)
|
||||
{
|
||||
if (($file !== null) && !array_key_exists('destination', $file)) {
|
||||
if (($file !== null) && ! array_key_exists('destination', $file)) {
|
||||
$file['destination'] = dirname($value);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ class Count extends AbstractValidator
|
||||
$value = $file['destination'] . DIRECTORY_SEPARATOR . $file['name'];
|
||||
}
|
||||
|
||||
if (($file === null) || !empty($file['tmp_name'])) {
|
||||
if (($file === null) || ! empty($file['tmp_name'])) {
|
||||
$this->addFile($value);
|
||||
}
|
||||
|
||||
|
@@ -56,7 +56,7 @@ class Crc32 extends Hash
|
||||
* Sets the crc32 hash for one or multiple files
|
||||
*
|
||||
* @param string|array $options
|
||||
* @return Crc32 Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setCrc32($options)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ class Crc32 extends Hash
|
||||
* Adds the crc32 hash for one or multiple files
|
||||
*
|
||||
* @param string|array $options
|
||||
* @return Crc32 Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function addCrc32($options)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ class Crc32 extends Hash
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -104,12 +104,12 @@ class Crc32 extends Hash
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
$hashes = array_unique(array_keys($this->getHash()));
|
||||
$hashes = array_unique(array_keys($this->getHash()));
|
||||
$filehash = hash_file('crc32', $file);
|
||||
if ($filehash === false) {
|
||||
$this->error(self::NOT_DETECTED);
|
||||
|
@@ -45,7 +45,7 @@ class ExcludeExtension extends Extension
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -59,7 +59,7 @@ class ExcludeExtension extends Extension
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
@@ -67,9 +67,9 @@ class ExcludeExtension extends Extension
|
||||
$extension = substr($filename, strrpos($filename, '.') + 1);
|
||||
$extensions = $this->getExtension();
|
||||
|
||||
if ($this->getCase() && (!in_array($extension, $extensions))) {
|
||||
if ($this->getCase() && (! in_array($extension, $extensions))) {
|
||||
return true;
|
||||
} elseif (!$this->getCase()) {
|
||||
} elseif (! $this->getCase()) {
|
||||
foreach ($extensions as $ext) {
|
||||
if (strtolower($ext) == strtolower($extension)) {
|
||||
$this->error(self::FALSE_EXTENSION);
|
||||
|
@@ -47,7 +47,7 @@ class ExcludeMimeType extends MimeType
|
||||
$filetype = $file['type'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name']) || !isset($value['type'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name']) || ! isset($value['type'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -63,14 +63,14 @@ class ExcludeMimeType extends MimeType
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_READABLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
$mimefile = $this->getMagicFile();
|
||||
if (class_exists('finfo', false)) {
|
||||
if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) {
|
||||
if (! $this->isMagicFileDisabled() && (! empty($mimefile) && empty($this->finfo))) {
|
||||
$this->finfo = finfo_open(FILEINFO_MIME_TYPE, $mimefile);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class ExcludeMimeType extends MimeType
|
||||
}
|
||||
|
||||
$this->type = null;
|
||||
if (!empty($this->finfo)) {
|
||||
if (! empty($this->finfo)) {
|
||||
$this->type = finfo_file($this->finfo, $file);
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class Exists extends AbstractValidator
|
||||
$options = explode(',', $options);
|
||||
}
|
||||
|
||||
if (is_array($options) && !array_key_exists('directory', $options)) {
|
||||
if (is_array($options) && ! array_key_exists('directory', $options)) {
|
||||
$options = ['directory' => $options];
|
||||
}
|
||||
|
||||
@@ -103,18 +103,18 @@ class Exists extends AbstractValidator
|
||||
public function addDirectory($directory)
|
||||
{
|
||||
$directories = $this->getDirectory(true);
|
||||
if (!isset($directories)) {
|
||||
if (! isset($directories)) {
|
||||
$directories = [];
|
||||
}
|
||||
|
||||
if (is_string($directory)) {
|
||||
$directory = explode(',', $directory);
|
||||
} elseif (!is_array($directory)) {
|
||||
} elseif (! is_array($directory)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid options to validator provided');
|
||||
}
|
||||
|
||||
foreach ($directory as $content) {
|
||||
if (empty($content) || !is_string($content)) {
|
||||
if (empty($content) || ! is_string($content)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ class Exists extends AbstractValidator
|
||||
}
|
||||
}
|
||||
|
||||
$this->options['directory'] = (!empty($directory))
|
||||
$this->options['directory'] = (! empty($directory))
|
||||
? implode(',', $directories) : null;
|
||||
|
||||
return $this;
|
||||
@@ -150,7 +150,7 @@ class Exists extends AbstractValidator
|
||||
$file = $file['tmp_name'];
|
||||
$this->setValue($filename);
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -166,27 +166,27 @@ class Exists extends AbstractValidator
|
||||
|
||||
$check = false;
|
||||
$directories = $this->getDirectory(true);
|
||||
if (!isset($directories)) {
|
||||
if (! isset($directories)) {
|
||||
$check = true;
|
||||
if (!file_exists($file)) {
|
||||
if (! file_exists($file)) {
|
||||
$this->error(self::DOES_NOT_EXIST);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
foreach ($directories as $directory) {
|
||||
if (!isset($directory) || '' === $directory) {
|
||||
if (! isset($directory) || '' === $directory) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$check = true;
|
||||
if (!file_exists($directory . DIRECTORY_SEPARATOR . $filename)) {
|
||||
if (! file_exists($directory . DIRECTORY_SEPARATOR . $filename)) {
|
||||
$this->error(self::DOES_NOT_EXIST);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$check) {
|
||||
if (! $check) {
|
||||
$this->error(self::DOES_NOT_EXIST);
|
||||
return false;
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ class Extension extends AbstractValidator
|
||||
unset($options['case']);
|
||||
}
|
||||
|
||||
if (!array_key_exists('extension', $options)) {
|
||||
if (! array_key_exists('extension', $options)) {
|
||||
$options = ['extension' => $options];
|
||||
}
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ class Extension extends AbstractValidator
|
||||
* Sets the case to use
|
||||
*
|
||||
* @param bool $case
|
||||
* @return Extension Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setCase($case)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ class Extension extends AbstractValidator
|
||||
* Sets the file extensions
|
||||
*
|
||||
* @param string|array $extension The extensions to validate
|
||||
* @return Extension Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setExtension($extension)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ class Extension extends AbstractValidator
|
||||
* Adds the file extensions
|
||||
*
|
||||
* @param string|array $extension The extensions to add for validation
|
||||
* @return Extension Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function addExtension($extension)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ class Extension extends AbstractValidator
|
||||
}
|
||||
|
||||
foreach ($extension as $content) {
|
||||
if (empty($content) || !is_string($content)) {
|
||||
if (empty($content) || ! is_string($content)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class Extension extends AbstractValidator
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -196,7 +196,7 @@ class Extension extends AbstractValidator
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ class Extension extends AbstractValidator
|
||||
|
||||
if ($this->getCase() && (in_array($extension, $extensions))) {
|
||||
return true;
|
||||
} elseif (!$this->getCase()) {
|
||||
} elseif (! $this->getCase()) {
|
||||
foreach ($extensions as $ext) {
|
||||
if (strtolower($ext) == strtolower($extension)) {
|
||||
return true;
|
||||
|
@@ -61,7 +61,7 @@ class FilesSize extends Size
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
} elseif (is_scalar($options)) {
|
||||
$options = ['max' => $options];
|
||||
} elseif (!is_array($options)) {
|
||||
} elseif (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid options to validator provided');
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class FilesSize extends Size
|
||||
$argv = func_get_args();
|
||||
array_shift($argv);
|
||||
$options['max'] = array_shift($argv);
|
||||
if (!empty($argv)) {
|
||||
if (! empty($argv)) {
|
||||
$options['useByteString'] = array_shift($argv);
|
||||
}
|
||||
}
|
||||
@@ -98,22 +98,22 @@ class FilesSize extends Size
|
||||
$size = $this->getSize();
|
||||
foreach ($value as $files) {
|
||||
if (is_array($files)) {
|
||||
if (!isset($files['tmp_name']) || !isset($files['name'])) {
|
||||
if (! isset($files['tmp_name']) || ! isset($files['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
}
|
||||
$file = $files;
|
||||
$file = $files;
|
||||
$files = $files['tmp_name'];
|
||||
}
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($files) || false === stream_resolve_include_path($files)) {
|
||||
if (empty($files) || false === is_readable($files)) {
|
||||
$this->throwError($file, self::NOT_READABLE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($this->files[$files])) {
|
||||
if (! isset($this->files[$files])) {
|
||||
$this->files[$files] = $files;
|
||||
} else {
|
||||
// file already counted... do not count twice
|
||||
@@ -128,10 +128,10 @@ class FilesSize extends Size
|
||||
if (($max !== null) && ($max < $size)) {
|
||||
if ($this->getByteString()) {
|
||||
$this->options['max'] = $this->toByteString($max);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->throwError($file, self::TOO_BIG);
|
||||
$this->options['max'] = $max;
|
||||
$this->size = $size;
|
||||
$this->size = $size;
|
||||
} else {
|
||||
$this->throwError($file, self::TOO_BIG);
|
||||
}
|
||||
@@ -142,10 +142,10 @@ class FilesSize extends Size
|
||||
if (($min !== null) && ($size < $min)) {
|
||||
if ($this->getByteString()) {
|
||||
$this->options['min'] = $this->toByteString($min);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->throwError($file, self::TOO_SMALL);
|
||||
$this->options['min'] = $min;
|
||||
$this->size = $size;
|
||||
$this->size = $size;
|
||||
} else {
|
||||
$this->throwError($file, self::TOO_SMALL);
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ class Hash extends AbstractValidator
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if (is_scalar($options) ||
|
||||
(is_array($options) && !array_key_exists('hash', $options))) {
|
||||
(is_array($options) && ! array_key_exists('hash', $options))) {
|
||||
$options = ['hash' => $options];
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class Hash extends AbstractValidator
|
||||
* Sets the hash for one or multiple files
|
||||
*
|
||||
* @param string|array $options
|
||||
* @return Hash Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setHash($options)
|
||||
{
|
||||
@@ -90,26 +90,26 @@ class Hash extends AbstractValidator
|
||||
* Adds the hash for one or multiple files
|
||||
*
|
||||
* @param string|array $options
|
||||
* @return Hash Provides a fluent interface
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function addHash($options)
|
||||
{
|
||||
if (is_string($options)) {
|
||||
$options = [$options];
|
||||
} elseif (!is_array($options)) {
|
||||
} elseif (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException("False parameter given");
|
||||
}
|
||||
|
||||
$known = hash_algos();
|
||||
if (!isset($options['algorithm'])) {
|
||||
if (! isset($options['algorithm'])) {
|
||||
$algorithm = $this->options['algorithm'];
|
||||
} else {
|
||||
$algorithm = $options['algorithm'];
|
||||
unset($options['algorithm']);
|
||||
}
|
||||
|
||||
if (!in_array($algorithm, $known)) {
|
||||
if (! in_array($algorithm, $known)) {
|
||||
throw new Exception\InvalidArgumentException("Unknown algorithm '{$algorithm}'");
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class Hash extends AbstractValidator
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -148,7 +148,7 @@ class Hash extends AbstractValidator
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
@@ -92,16 +92,16 @@ class ImageSize extends AbstractValidator
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if (1 < func_num_args()) {
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = ['minWidth' => $options];
|
||||
}
|
||||
|
||||
$argv = func_get_args();
|
||||
array_shift($argv);
|
||||
$options['minHeight'] = array_shift($argv);
|
||||
if (!empty($argv)) {
|
||||
if (! empty($argv)) {
|
||||
$options['maxWidth'] = array_shift($argv);
|
||||
if (!empty($argv)) {
|
||||
if (! empty($argv)) {
|
||||
$options['maxHeight'] = array_shift($argv);
|
||||
}
|
||||
}
|
||||
@@ -124,8 +124,8 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the minimum allowed width
|
||||
*
|
||||
* @param int $minWidth
|
||||
* @return ImageSize Provides a fluid interface
|
||||
* @throws Exception\InvalidArgumentException When minwidth is greater than maxwidth
|
||||
* @return self Provides a fluid interface
|
||||
*/
|
||||
public function setMinWidth($minWidth)
|
||||
{
|
||||
@@ -154,8 +154,8 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the maximum allowed width
|
||||
*
|
||||
* @param int $maxWidth
|
||||
* @return ImageSize Provides a fluid interface
|
||||
* @throws Exception\InvalidArgumentException When maxwidth is less than minwidth
|
||||
* @return self Provides a fluid interface
|
||||
*/
|
||||
public function setMaxWidth($maxWidth)
|
||||
{
|
||||
@@ -184,8 +184,8 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the minimum allowed height
|
||||
*
|
||||
* @param int $minHeight
|
||||
* @return ImageSize Provides a fluid interface
|
||||
* @throws Exception\InvalidArgumentException When minheight is greater than maxheight
|
||||
* @return self Provides a fluid interface
|
||||
*/
|
||||
public function setMinHeight($minHeight)
|
||||
{
|
||||
@@ -214,8 +214,8 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the maximum allowed height
|
||||
*
|
||||
* @param int $maxHeight
|
||||
* @return ImageSize Provides a fluid interface
|
||||
* @throws Exception\InvalidArgumentException When maxheight is less than minheight
|
||||
* @return self Provides a fluid interface
|
||||
*/
|
||||
public function setMaxHeight($maxHeight)
|
||||
{
|
||||
@@ -274,7 +274,7 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the minimum image size
|
||||
*
|
||||
* @param array $options The minimum image dimensions
|
||||
* @return ImageSize Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setImageMin($options)
|
||||
{
|
||||
@@ -286,7 +286,7 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the maximum image size
|
||||
*
|
||||
* @param array|\Traversable $options The maximum image dimensions
|
||||
* @return ImageSize Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setImageMax($options)
|
||||
{
|
||||
@@ -298,7 +298,7 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the minimum and maximum image width
|
||||
*
|
||||
* @param array $options The image width dimensions
|
||||
* @return ImageSize Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setImageWidth($options)
|
||||
{
|
||||
@@ -312,7 +312,7 @@ class ImageSize extends AbstractValidator
|
||||
* Sets the minimum and maximum image height
|
||||
*
|
||||
* @param array $options The image height dimensions
|
||||
* @return ImageSize Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setImageHeight($options)
|
||||
{
|
||||
@@ -337,7 +337,7 @@ class ImageSize extends AbstractValidator
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -351,7 +351,7 @@ class ImageSize extends AbstractValidator
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_READABLE);
|
||||
return false;
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ class IsCompressed extends MimeType
|
||||
|
||||
parent::__construct($options);
|
||||
|
||||
if (!$this->getMimeType()) {
|
||||
if (! $this->getMimeType()) {
|
||||
$this->setMimeType($default);
|
||||
}
|
||||
}
|
||||
|
@@ -109,7 +109,7 @@ class IsImage extends MimeType
|
||||
|
||||
parent::__construct($options);
|
||||
|
||||
if (!$this->getMimeType()) {
|
||||
if (! $this->getMimeType()) {
|
||||
$this->setMimeType($default);
|
||||
}
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ class Md5 extends Hash
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -104,12 +104,12 @@ class Md5 extends Hash
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
$hashes = array_unique(array_keys($this->getHash()));
|
||||
$hashes = array_unique(array_keys($this->getHash()));
|
||||
$filehash = hash_file('md5', $file);
|
||||
if ($filehash === false) {
|
||||
$this->error(self::NOT_DETECTED);
|
||||
|
@@ -120,7 +120,7 @@ class MimeType extends AbstractValidator
|
||||
// Handle cases where mimetypes are interspersed with options, or
|
||||
// options are simply an array of mime types
|
||||
foreach (array_keys($options) as $key) {
|
||||
if (!is_int($key)) {
|
||||
if (! is_int($key)) {
|
||||
continue;
|
||||
}
|
||||
$this->addMimeType($options[$key]);
|
||||
@@ -140,7 +140,7 @@ class MimeType extends AbstractValidator
|
||||
{
|
||||
if (null === $this->options['magicFile']) {
|
||||
$magic = getenv('magic');
|
||||
if (!empty($magic)) {
|
||||
if (! empty($magic)) {
|
||||
$this->setMagicFile($magic);
|
||||
if ($this->options['magicFile'] === null) {
|
||||
$this->options['magicFile'] = false;
|
||||
@@ -176,10 +176,10 @@ class MimeType extends AbstractValidator
|
||||
* if false, the default MAGIC file from PHP will be used
|
||||
*
|
||||
* @param string $file
|
||||
* @return MimeType Provides fluid interface
|
||||
* @throws Exception\RuntimeException When finfo can not read the magicfile
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @throws Exception\InvalidMagicMimeFileException
|
||||
* @return self Provides fluid interface
|
||||
*/
|
||||
public function setMagicFile($file)
|
||||
{
|
||||
@@ -187,16 +187,16 @@ class MimeType extends AbstractValidator
|
||||
$this->options['magicFile'] = false;
|
||||
} elseif (empty($file)) {
|
||||
$this->options['magicFile'] = null;
|
||||
} elseif (!(class_exists('finfo', false))) {
|
||||
} elseif (! (class_exists('finfo', false))) {
|
||||
$this->options['magicFile'] = null;
|
||||
throw new Exception\RuntimeException('Magicfile can not be set; there is no finfo extension installed');
|
||||
} elseif (!is_file($file) || !is_readable($file)) {
|
||||
} elseif (! is_file($file) || ! is_readable($file)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'The given magicfile ("%s") could not be read',
|
||||
$file
|
||||
));
|
||||
} else {
|
||||
ErrorHandler::start(E_NOTICE|E_WARNING);
|
||||
ErrorHandler::start(E_NOTICE | E_WARNING);
|
||||
$this->finfo = finfo_open(FILEINFO_MIME_TYPE, $file);
|
||||
$error = ErrorHandler::stop();
|
||||
if (empty($this->finfo)) {
|
||||
@@ -216,7 +216,7 @@ class MimeType extends AbstractValidator
|
||||
* Disables usage of MagicFile
|
||||
*
|
||||
* @param $disable boolean False disables usage of magic file
|
||||
* @return MimeType Provides fluid interface
|
||||
* @return self Provides fluid interface
|
||||
*/
|
||||
public function disableMagicFile($disable)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ class MimeType extends AbstractValidator
|
||||
* Note that this is unsafe and therefor the default value is false
|
||||
*
|
||||
* @param bool $headerCheck
|
||||
* @return MimeType Provides fluid interface
|
||||
* @return self Provides fluid interface
|
||||
*/
|
||||
public function enableHeaderCheck($headerCheck = true)
|
||||
{
|
||||
@@ -278,7 +278,7 @@ class MimeType extends AbstractValidator
|
||||
* Sets the mimetypes
|
||||
*
|
||||
* @param string|array $mimetype The mimetypes to validate
|
||||
* @return MimeType Provides a fluent interface
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setMimeType($mimetype)
|
||||
{
|
||||
@@ -291,8 +291,8 @@ class MimeType extends AbstractValidator
|
||||
* Adds the mimetypes
|
||||
*
|
||||
* @param string|array $mimetype The mimetypes to add for validation
|
||||
* @return MimeType Provides a fluent interface
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function addMimeType($mimetype)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ class MimeType extends AbstractValidator
|
||||
|
||||
if (is_string($mimetype)) {
|
||||
$mimetype = explode(',', $mimetype);
|
||||
} elseif (!is_array($mimetype)) {
|
||||
} elseif (! is_array($mimetype)) {
|
||||
throw new Exception\InvalidArgumentException("Invalid options to validator provided");
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ class MimeType extends AbstractValidator
|
||||
}
|
||||
|
||||
foreach ($mimetype as $content) {
|
||||
if (empty($content) || !is_string($content)) {
|
||||
if (empty($content) || ! is_string($content)) {
|
||||
continue;
|
||||
}
|
||||
$mimetypes[] = trim($content);
|
||||
@@ -347,7 +347,7 @@ class MimeType extends AbstractValidator
|
||||
$filetype = $file['type'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name']) || !isset($value['type'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name']) || ! isset($value['type'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -363,28 +363,29 @@ class MimeType extends AbstractValidator
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(static::NOT_READABLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
$mimefile = $this->getMagicFile();
|
||||
if (class_exists('finfo', false)) {
|
||||
if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) {
|
||||
ErrorHandler::start(E_NOTICE|E_WARNING);
|
||||
if (! $this->isMagicFileDisabled() && (! empty($mimefile) && empty($this->finfo))) {
|
||||
ErrorHandler::start(E_NOTICE | E_WARNING);
|
||||
$this->finfo = finfo_open(FILEINFO_MIME_TYPE, $mimefile);
|
||||
ErrorHandler::stop();
|
||||
}
|
||||
|
||||
if (empty($this->finfo)) {
|
||||
ErrorHandler::start(E_NOTICE|E_WARNING);
|
||||
ErrorHandler::start(E_NOTICE | E_WARNING);
|
||||
$this->finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
ErrorHandler::stop();
|
||||
}
|
||||
|
||||
$this->type = null;
|
||||
if (!empty($this->finfo)) {
|
||||
if (! empty($this->finfo)) {
|
||||
$this->type = finfo_file($this->finfo, $file);
|
||||
unset($this->finfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ class NotExists extends Exists
|
||||
$file = $file['tmp_name'];
|
||||
$this->setValue($filename);
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -59,7 +59,7 @@ class NotExists extends Exists
|
||||
|
||||
$check = false;
|
||||
$directories = $this->getDirectory(true);
|
||||
if (!isset($directories)) {
|
||||
if (! isset($directories)) {
|
||||
$check = true;
|
||||
if (file_exists($file)) {
|
||||
$this->error(self::DOES_EXIST);
|
||||
@@ -67,7 +67,7 @@ class NotExists extends Exists
|
||||
}
|
||||
} else {
|
||||
foreach ($directories as $directory) {
|
||||
if (!isset($directory) || '' === $directory) {
|
||||
if (! isset($directory) || '' === $directory) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class NotExists extends Exists
|
||||
}
|
||||
}
|
||||
|
||||
if (!$check) {
|
||||
if (! $check) {
|
||||
$this->error(self::DOES_EXIST);
|
||||
return false;
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ class Sha1 extends Hash
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -104,12 +104,12 @@ class Sha1 extends Hash
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
$hashes = array_unique(array_keys($this->getHash()));
|
||||
$hashes = array_unique(array_keys($this->getHash()));
|
||||
$filehash = hash_file('sha1', $file);
|
||||
if ($filehash === false) {
|
||||
$this->error(self::NOT_DETECTED);
|
||||
|
@@ -82,7 +82,7 @@ class Size extends AbstractValidator
|
||||
$argv = func_get_args();
|
||||
array_shift($argv);
|
||||
$options['max'] = array_shift($argv);
|
||||
if (!empty($argv)) {
|
||||
if (! empty($argv)) {
|
||||
$options['useByteString'] = array_shift($argv);
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class Size extends AbstractValidator
|
||||
public function getMin($raw = false)
|
||||
{
|
||||
$min = $this->options['min'];
|
||||
if (!$raw && $this->getByteString()) {
|
||||
if (! $raw && $this->getByteString()) {
|
||||
$min = $this->toByteString($min);
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ class Size extends AbstractValidator
|
||||
* For example: 2000, 2MB, 0.2GB
|
||||
*
|
||||
* @param int|string $min The minimum file size
|
||||
* @return Size Provides a fluent interface
|
||||
* @throws Exception\InvalidArgumentException When min is greater than max
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setMin($min)
|
||||
{
|
||||
@@ -166,7 +166,7 @@ class Size extends AbstractValidator
|
||||
public function getMax($raw = false)
|
||||
{
|
||||
$max = $this->options['max'];
|
||||
if (!$raw && $this->getByteString()) {
|
||||
if (! $raw && $this->getByteString()) {
|
||||
$max = $this->toByteString($max);
|
||||
}
|
||||
|
||||
@@ -181,8 +181,8 @@ class Size extends AbstractValidator
|
||||
* For example: 2000, 2MB, 0.2GB
|
||||
*
|
||||
* @param int|string $max The maximum file size
|
||||
* @return Size Provides a fluent interface
|
||||
* @throws Exception\InvalidArgumentException When max is smaller than min
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setMax($max)
|
||||
{
|
||||
@@ -216,7 +216,7 @@ class Size extends AbstractValidator
|
||||
* Set current size
|
||||
*
|
||||
* @param int $size
|
||||
* @return Size
|
||||
* @return self
|
||||
*/
|
||||
protected function setSize($size)
|
||||
{
|
||||
@@ -239,7 +239,7 @@ class Size extends AbstractValidator
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -253,7 +253,7 @@ class Size extends AbstractValidator
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
@@ -270,10 +270,10 @@ class Size extends AbstractValidator
|
||||
if (($min !== null) && ($size < $min)) {
|
||||
if ($this->getByteString()) {
|
||||
$this->options['min'] = $this->toByteString($min);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->error(self::TOO_SMALL);
|
||||
$this->options['min'] = $min;
|
||||
$this->size = $size;
|
||||
$this->size = $size;
|
||||
} else {
|
||||
$this->error(self::TOO_SMALL);
|
||||
}
|
||||
@@ -283,10 +283,10 @@ class Size extends AbstractValidator
|
||||
if (($max !== null) && ($max < $size)) {
|
||||
if ($this->getByteString()) {
|
||||
$this->options['max'] = $this->toByteString($max);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->size = $this->toByteString($size);
|
||||
$this->error(self::TOO_BIG);
|
||||
$this->options['max'] = $max;
|
||||
$this->size = $size;
|
||||
$this->size = $size;
|
||||
} else {
|
||||
$this->error(self::TOO_BIG);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ class Size extends AbstractValidator
|
||||
protected function toByteString($size)
|
||||
{
|
||||
$sizes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
for ($i=0; $size >= 1024 && $i < 9; $i++) {
|
||||
for ($i = 0; $size >= 1024 && $i < 9; $i++) {
|
||||
$size /= 1024;
|
||||
}
|
||||
|
||||
@@ -330,8 +330,8 @@ class Size extends AbstractValidator
|
||||
$type = trim(substr($size, -2, 1));
|
||||
|
||||
$value = substr($size, 0, -1);
|
||||
if (!is_numeric($value)) {
|
||||
$value = substr($value, 0, -1);
|
||||
if (! is_numeric($value)) {
|
||||
$value = trim(substr($value, 0, -1));
|
||||
}
|
||||
|
||||
switch (strtoupper($type)) {
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace Zend\Validator\File;
|
||||
|
||||
use Countable;
|
||||
use Zend\Validator\AbstractValidator;
|
||||
use Zend\Validator\Exception;
|
||||
|
||||
@@ -63,7 +64,7 @@ class Upload extends AbstractValidator
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
if (is_array($options) && !array_key_exists('files', $options)) {
|
||||
if (is_array($options) && ! array_key_exists('files', $options)) {
|
||||
$options = ['files' => $options];
|
||||
}
|
||||
|
||||
@@ -109,7 +110,10 @@ class Upload extends AbstractValidator
|
||||
*/
|
||||
public function setFiles($files = [])
|
||||
{
|
||||
if (count($files) === 0) {
|
||||
if (null === $files
|
||||
|| ((is_array($files) || $files instanceof Countable)
|
||||
&& count($files) === 0)
|
||||
) {
|
||||
$this->options['files'] = $_FILES;
|
||||
} else {
|
||||
$this->options['files'] = $files;
|
||||
@@ -120,7 +124,7 @@ class Upload extends AbstractValidator
|
||||
}
|
||||
|
||||
foreach ($this->options['files'] as $file => $content) {
|
||||
if (!isset($content['error'])) {
|
||||
if (! isset($content['error'])) {
|
||||
unset($this->options['files'][$file]);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +166,7 @@ class Upload extends AbstractValidator
|
||||
$this->value = $file;
|
||||
switch ($content['error']) {
|
||||
case 0:
|
||||
if (!is_uploaded_file($content['tmp_name'])) {
|
||||
if (! is_uploaded_file($content['tmp_name'])) {
|
||||
$this->throwError($content, self::ATTACK);
|
||||
}
|
||||
break;
|
||||
|
@@ -57,7 +57,7 @@ class UploadFile extends AbstractValidator
|
||||
public function isValid($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name']) || !isset($value['error'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name']) || ! isset($value['error'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
|
@@ -28,8 +28,8 @@ class WordCount extends AbstractValidator
|
||||
* @var array Error message templates
|
||||
*/
|
||||
protected $messageTemplates = [
|
||||
self::TOO_MUCH => "Too many words, maximum '%max%' are allowed but '%count%' were counted",
|
||||
self::TOO_LESS => "Too few words, minimum '%min%' are expected but '%count%' were counted",
|
||||
self::TOO_MUCH => "Too many words, maximum '%max%' are allowed but '%count%' were counted",
|
||||
self::TOO_LESS => "Too few words, minimum '%min%' are expected but '%count%' were counted",
|
||||
self::NOT_FOUND => "File is not readable or does not exist",
|
||||
];
|
||||
|
||||
@@ -75,7 +75,7 @@ class WordCount extends AbstractValidator
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if (1 < func_num_args()) {
|
||||
$args = func_get_args();
|
||||
$args = func_get_args();
|
||||
$options = [
|
||||
'min' => array_shift($args),
|
||||
'max' => array_shift($args),
|
||||
@@ -103,8 +103,8 @@ class WordCount extends AbstractValidator
|
||||
* Sets the minimum word count
|
||||
*
|
||||
* @param int|array $min The minimum word count
|
||||
* @return WordCount Provides a fluent interface
|
||||
* @throws Exception\InvalidArgumentException When min is greater than max
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setMin($min)
|
||||
{
|
||||
@@ -141,8 +141,8 @@ class WordCount extends AbstractValidator
|
||||
* Sets the maximum file count
|
||||
*
|
||||
* @param int|array $max The maximum word count
|
||||
* @return WordCount Provides a fluent interface
|
||||
* @throws Exception\InvalidArgumentException When max is smaller than min
|
||||
* @return self Provides a fluent interface
|
||||
*/
|
||||
public function setMax($max)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ class WordCount extends AbstractValidator
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
} elseif (is_array($value)) {
|
||||
if (!isset($value['tmp_name']) || !isset($value['name'])) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
@@ -194,7 +194,7 @@ class WordCount extends AbstractValidator
|
||||
$this->setValue($filename);
|
||||
|
||||
// Is file readable ?
|
||||
if (empty($file) || false === stream_resolve_include_path($file)) {
|
||||
if (empty($file) || false === is_readable($file)) {
|
||||
$this->error(self::NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
@@ -108,7 +108,7 @@ final class GpsPoint extends AbstractValidator
|
||||
return false;
|
||||
}
|
||||
|
||||
return $matches[1][0] + $matches[2][0]/60 + ((double)$matches[3][0])/3600;
|
||||
return $matches[1][0] + $matches[2][0] / 60 + ((double)$matches[3][0]) / 3600;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -62,22 +62,22 @@ class GreaterThan extends AbstractValidator
|
||||
if ($options instanceof Traversable) {
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['min'] = array_shift($options);
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['inclusive'] = array_shift($options);
|
||||
}
|
||||
|
||||
$options = $temp;
|
||||
}
|
||||
|
||||
if (!array_key_exists('min', $options)) {
|
||||
if (! array_key_exists('min', $options)) {
|
||||
throw new Exception\InvalidArgumentException("Missing option 'min'");
|
||||
}
|
||||
|
||||
if (!array_key_exists('inclusive', $options)) {
|
||||
if (! array_key_exists('inclusive', $options)) {
|
||||
$options['inclusive'] = false;
|
||||
}
|
||||
|
||||
|
@@ -32,13 +32,13 @@ class Hex extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value) && !is_int($value)) {
|
||||
if (! is_string($value) && ! is_int($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setValue($value);
|
||||
if (!ctype_xdigit((string) $value)) {
|
||||
if (! ctype_xdigit((string) $value)) {
|
||||
$this->error(self::NOT_HEX);
|
||||
return false;
|
||||
}
|
||||
|
343
vendor/zendframework/zend-validator/src/Hostname.php
vendored
343
vendor/zendframework/zend-validator/src/Hostname.php
vendored
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,9 @@ return [
|
||||
1 => '/^[\x{002d}0-9\x{0400}-\x{052f}]{1,63}$/iu',
|
||||
2 => '/^[\x{002d}0-9\x{0370}-\x{03ff}]{1,63}$/iu',
|
||||
3 => '/^[\x{002d}0-9a-z\x{ac00}-\x{d7a3}]{1,17}$/iu',
|
||||
// @codingStandardsIgnoreStart
|
||||
4 => '/^[\x{002d}0-9a-z·à-öø-ÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĸĺļľłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž]{1,63}$/iu',
|
||||
// @codingStandardsIgnoreEnd
|
||||
5 => '/^[\x{002d}0-9A-Za-z\x{3400}-\x{3401}\x{3404}-\x{3406}\x{340C}\x{3416}\x{341C}' .
|
||||
'\x{3421}\x{3424}\x{3428}-\x{3429}\x{342B}-\x{342E}\x{3430}-\x{3434}\x{3436}' .
|
||||
'\x{3438}-\x{343C}\x{343E}\x{3441}-\x{3445}\x{3447}\x{3449}-\x{3451}\x{3453}' .
|
||||
|
14
vendor/zendframework/zend-validator/src/Iban.php
vendored
14
vendor/zendframework/zend-validator/src/Iban.php
vendored
@@ -56,7 +56,8 @@ class Iban extends AbstractValidator
|
||||
protected static $sepaCountries = [
|
||||
'AT', 'BE', 'BG', 'CY', 'CZ', 'DK', 'FO', 'GL', 'EE', 'FI', 'FR', 'DE',
|
||||
'GI', 'GR', 'HU', 'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'MC',
|
||||
'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH', 'GB'
|
||||
'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH', 'GB', 'SM',
|
||||
'HR',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -75,6 +76,7 @@ class Iban extends AbstractValidator
|
||||
'BG' => 'BG[0-9]{2}[A-Z]{4}[0-9]{4}[0-9]{2}[A-Z0-9]{8}',
|
||||
'BH' => 'BH[0-9]{2}[A-Z]{4}[A-Z0-9]{14}',
|
||||
'BR' => 'BR[0-9]{2}[0-9]{8}[0-9]{5}[0-9]{10}[A-Z][A-Z0-9]',
|
||||
'BY' => 'BY[0-9]{2}[A-Z0-9]{4}[0-9]{4}[A-Z0-9]{16}',
|
||||
'CH' => 'CH[0-9]{2}[0-9]{5}[A-Z0-9]{12}',
|
||||
'CR' => 'CR[0-9]{2}[0-9]{3}[0-9]{14}',
|
||||
'CY' => 'CY[0-9]{2}[0-9]{3}[0-9]{5}[A-Z0-9]{16}',
|
||||
@@ -175,7 +177,7 @@ class Iban extends AbstractValidator
|
||||
if ($countryCode !== null) {
|
||||
$countryCode = (string) $countryCode;
|
||||
|
||||
if (!isset(static::$ibanRegex[$countryCode])) {
|
||||
if (! isset(static::$ibanRegex[$countryCode])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
"Country code '{$countryCode}' invalid by ISO 3166-1 or not supported"
|
||||
);
|
||||
@@ -216,7 +218,7 @@ class Iban extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::FALSEFORMAT);
|
||||
return false;
|
||||
}
|
||||
@@ -229,19 +231,19 @@ class Iban extends AbstractValidator
|
||||
$countryCode = substr($value, 0, 2);
|
||||
}
|
||||
|
||||
if (!array_key_exists($countryCode, static::$ibanRegex)) {
|
||||
if (! array_key_exists($countryCode, static::$ibanRegex)) {
|
||||
$this->setValue($countryCode);
|
||||
$this->error(self::NOTSUPPORTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->allowNonSepa && !in_array($countryCode, static::$sepaCountries)) {
|
||||
if (! $this->allowNonSepa && ! in_array($countryCode, static::$sepaCountries)) {
|
||||
$this->setValue($countryCode);
|
||||
$this->error(self::SEPANOTSUPPORTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!preg_match('/^' . static::$ibanRegex[$countryCode] . '$/', $value)) {
|
||||
if (! preg_match('/^' . static::$ibanRegex[$countryCode] . '$/', $value)) {
|
||||
$this->error(self::FALSEFORMAT);
|
||||
return false;
|
||||
}
|
||||
|
@@ -157,8 +157,8 @@ class Identical extends AbstractValidator
|
||||
|
||||
$token = $this->getToken();
|
||||
|
||||
if (!$this->getLiteral() && $context !== null) {
|
||||
if (!is_array($context) && !($context instanceof ArrayAccess)) {
|
||||
if (! $this->getLiteral() && $context !== null) {
|
||||
if (! is_array($context) && ! ($context instanceof ArrayAccess)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Context passed to %s must be array, ArrayObject or null; received "%s"',
|
||||
__METHOD__,
|
||||
@@ -169,7 +169,7 @@ class Identical extends AbstractValidator
|
||||
if (is_array($token)) {
|
||||
while (is_array($token)) {
|
||||
$key = key($token);
|
||||
if (!isset($context[$key])) {
|
||||
if (! isset($context[$key])) {
|
||||
break;
|
||||
}
|
||||
$context = $context[$key];
|
||||
@@ -179,7 +179,7 @@ class Identical extends AbstractValidator
|
||||
|
||||
// if $token is an array it means the above loop didn't went all the way down to the leaf,
|
||||
// so the $token structure doesn't match the $context structure
|
||||
if (is_array($token) || !isset($context[$token])) {
|
||||
if (is_array($token) || ! isset($context[$token])) {
|
||||
$token = $this->getToken();
|
||||
} else {
|
||||
$token = $context[$token];
|
||||
@@ -192,7 +192,7 @@ class Identical extends AbstractValidator
|
||||
}
|
||||
|
||||
$strict = $this->getStrict();
|
||||
if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) {
|
||||
if (($strict && ($value !== $token)) || (! $strict && ($value != $token))) {
|
||||
$this->error(self::NOT_SAME);
|
||||
return false;
|
||||
}
|
||||
|
@@ -110,7 +110,9 @@ class InArray extends AbstractValidator
|
||||
|
||||
/**
|
||||
* Sets the strict option mode
|
||||
* InArray::COMPARE_STRICT | InArray::COMPARE_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY | InArray::COMPARE_NOT_STRICT
|
||||
* InArray::COMPARE_STRICT
|
||||
* InArray::COMPARE_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY
|
||||
* InArray::COMPARE_NOT_STRICT
|
||||
*
|
||||
* @param int $strict
|
||||
* @return InArray Provides a fluent interface
|
||||
@@ -125,7 +127,7 @@ class InArray extends AbstractValidator
|
||||
];
|
||||
|
||||
// validate strict value
|
||||
if (!in_array($strict, $checkTypes)) {
|
||||
if (! in_array($strict, $checkTypes)) {
|
||||
throw new Exception\InvalidArgumentException('Strict option must be one of the COMPARE_ constants');
|
||||
}
|
||||
|
||||
|
@@ -40,14 +40,15 @@ class Ip extends AbstractValidator
|
||||
* Sets the options for this validator
|
||||
*
|
||||
* @param array|Traversable $options
|
||||
* @throws Exception\InvalidArgumentException If there is any kind of IP allowed or $options is not an array or Traversable.
|
||||
* @throws Exception\InvalidArgumentException If there is any kind of IP allowed or $options is not an array
|
||||
* or Traversable.
|
||||
* @return AbstractValidator
|
||||
*/
|
||||
public function setOptions($options = [])
|
||||
{
|
||||
parent::setOptions($options);
|
||||
|
||||
if (!$this->options['allowipv4'] && !$this->options['allowipv6'] && !$this->options['allowipvfuture']) {
|
||||
if (! $this->options['allowipv4'] && ! $this->options['allowipv6'] && ! $this->options['allowipvfuture']) {
|
||||
throw new Exception\InvalidArgumentException('Nothing to validate. Check your options');
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ class Ip extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
@@ -134,7 +135,7 @@ class Ip extends AbstractValidator
|
||||
|
||||
if (strpos($value, '.')) {
|
||||
$lastcolon = strrpos($value, ':');
|
||||
if (!($lastcolon && $this->validateIPv4(substr($value, $lastcolon + 1)))) {
|
||||
if (! ($lastcolon && $this->validateIPv4(substr($value, $lastcolon + 1)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
197
vendor/zendframework/zend-validator/src/IsCountable.php
vendored
Normal file
197
vendor/zendframework/zend-validator/src/IsCountable.php
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* @see https://github.com/zendframework/zend-validator for the canonical source repository
|
||||
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license https://github.com/zendframework/zend-validator/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Validator;
|
||||
|
||||
use Countable;
|
||||
|
||||
/**
|
||||
* Validate that a value is countable and the count meets expectations.
|
||||
*
|
||||
* The validator has five specific behaviors:
|
||||
*
|
||||
* - You can determine if a value is countable only
|
||||
* - You can test if the value is an exact count
|
||||
* - You can test if the value is greater than a minimum count value
|
||||
* - You can test if the value is greater than a maximum count value
|
||||
* - You can test if the value is between the minimum and maximum count values
|
||||
*
|
||||
* When creating the instance or calling `setOptions()`, if you specify a
|
||||
* "count" option, specifying either "min" or "max" leads to an inconsistent
|
||||
* state and, as such will raise an Exception\InvalidArgumentException.
|
||||
*/
|
||||
class IsCountable extends AbstractValidator
|
||||
{
|
||||
const NOT_COUNTABLE = 'notCountable';
|
||||
const NOT_EQUALS = 'notEquals';
|
||||
const GREATER_THAN = 'greaterThan';
|
||||
const LESS_THAN = 'lessThan';
|
||||
|
||||
/**
|
||||
* Validation failure message template definitions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $messageTemplates = [
|
||||
self::NOT_COUNTABLE => "The input must be an array or an instance of \\Countable",
|
||||
self::NOT_EQUALS => "The input count must equal '%count%'",
|
||||
self::GREATER_THAN => "The input count must be less than '%max%', inclusively",
|
||||
self::LESS_THAN => "The input count must be greater than '%min%', inclusively",
|
||||
];
|
||||
|
||||
/**
|
||||
* Additional variables available for validation failure messages
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $messageVariables = [
|
||||
'count' => ['options' => 'count'],
|
||||
'min' => ['options' => 'min'],
|
||||
'max' => ['options' => 'max'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Options for the between validator
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [
|
||||
'count' => null,
|
||||
'min' => null,
|
||||
'max' => null,
|
||||
];
|
||||
|
||||
public function setOptions($options = [])
|
||||
{
|
||||
foreach (['count', 'min', 'max'] as $option) {
|
||||
if (! is_array($options) || ! isset($options[$option])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = sprintf('set%s', ucfirst($option));
|
||||
$this->$method($options[$option]);
|
||||
unset($options[$option]);
|
||||
}
|
||||
|
||||
return parent::setOptions($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if $value is countable (and the count validates against optional values).
|
||||
*
|
||||
* @param iterable $value
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (! (is_array($value) || $value instanceof Countable)) {
|
||||
$this->error(self::NOT_COUNTABLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
$count = count($value);
|
||||
|
||||
if (is_numeric($this->getCount())) {
|
||||
if ($count != $this->getCount()) {
|
||||
$this->error(self::NOT_EQUALS);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_numeric($this->getMax()) && $count > $this->getMax()) {
|
||||
$this->error(self::GREATER_THAN);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_numeric($this->getMin()) && $count < $this->getMin()) {
|
||||
$this->error(self::LESS_THAN);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count option
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCount()
|
||||
{
|
||||
return $this->options['count'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the min option
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMin()
|
||||
{
|
||||
return $this->options['min'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max option
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMax()
|
||||
{
|
||||
return $this->options['max'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if either a min or max option
|
||||
* was previously set.
|
||||
*/
|
||||
private function setCount($value)
|
||||
{
|
||||
if (isset($this->options['min']) || isset($this->options['max'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Cannot set count; conflicts with either a min or max option previously set'
|
||||
);
|
||||
}
|
||||
$this->options['count'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if either a count or max option
|
||||
* was previously set.
|
||||
*/
|
||||
private function setMin($value)
|
||||
{
|
||||
if (isset($this->options['count'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Cannot set count; conflicts with either a count option previously set'
|
||||
);
|
||||
}
|
||||
$this->options['min'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if either a count or min option
|
||||
* was previously set.
|
||||
*/
|
||||
private function setMax($value)
|
||||
{
|
||||
if (isset($this->options['count'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Cannot set count; conflicts with either a count option previously set'
|
||||
);
|
||||
}
|
||||
$this->options['max'] = $value;
|
||||
}
|
||||
}
|
@@ -52,7 +52,7 @@ class IsInstanceOf extends AbstractValidator
|
||||
}
|
||||
|
||||
// If argument is not an array, consider first argument as class name
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
|
||||
$tmpOptions = [];
|
||||
@@ -61,7 +61,7 @@ class IsInstanceOf extends AbstractValidator
|
||||
$options = $tmpOptions;
|
||||
}
|
||||
|
||||
if (!array_key_exists('className', $options)) {
|
||||
if (! array_key_exists('className', $options)) {
|
||||
throw new Exception\InvalidArgumentException('Missing option "className"');
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,9 @@ class Isbn extends AbstractValidator
|
||||
$pattern = '/^[0-9]{13}$/';
|
||||
$length = 13;
|
||||
} else {
|
||||
// @codingStandardsIgnoreStart
|
||||
$pattern = "/^[0-9]{1,9}[{$sep}]{1}[0-9]{1,5}[{$sep}]{1}[0-9]{1,9}[{$sep}]{1}[0-9]{1,9}[{$sep}]{1}[0-9]{1}$/";
|
||||
// @codingStandardsIgnoreEnd
|
||||
$length = 17;
|
||||
}
|
||||
|
||||
@@ -91,7 +93,7 @@ class Isbn extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value) && !is_int($value)) {
|
||||
if (! is_string($value) && ! is_int($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
@@ -136,7 +138,7 @@ class Isbn extends AbstractValidator
|
||||
public function setSeparator($separator)
|
||||
{
|
||||
// check separator
|
||||
if (!in_array($separator, ['-', ' ', ''])) {
|
||||
if (! in_array($separator, ['-', ' ', ''])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid ISBN separator.');
|
||||
}
|
||||
|
||||
@@ -164,7 +166,7 @@ class Isbn extends AbstractValidator
|
||||
public function setType($type)
|
||||
{
|
||||
// check type
|
||||
if (!in_array($type, [self::AUTO, self::ISBN10, self::ISBN13])) {
|
||||
if (! in_array($type, [self::AUTO, self::ISBN10, self::ISBN13])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid ISBN type');
|
||||
}
|
||||
|
||||
|
@@ -64,22 +64,22 @@ class LessThan extends AbstractValidator
|
||||
if ($options instanceof Traversable) {
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['max'] = array_shift($options);
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['inclusive'] = array_shift($options);
|
||||
}
|
||||
|
||||
$options = $temp;
|
||||
}
|
||||
|
||||
if (!array_key_exists('max', $options)) {
|
||||
if (! array_key_exists('max', $options)) {
|
||||
throw new Exception\InvalidArgumentException("Missing option 'max'");
|
||||
}
|
||||
|
||||
if (!array_key_exists('inclusive', $options)) {
|
||||
if (! array_key_exists('inclusive', $options)) {
|
||||
$options['inclusive'] = false;
|
||||
}
|
||||
|
||||
|
@@ -83,36 +83,25 @@ class NotEmpty extends AbstractValidator
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
$this->setType($this->defaultType);
|
||||
|
||||
if ($options instanceof Traversable) {
|
||||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp = [];
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['type'] = array_shift($options);
|
||||
}
|
||||
|
||||
$options = $temp;
|
||||
}
|
||||
|
||||
if (is_array($options)) {
|
||||
if (!array_key_exists('type', $options)) {
|
||||
$detected = 0;
|
||||
$found = false;
|
||||
foreach ($options as $option) {
|
||||
if (in_array($option, $this->constants, true)) {
|
||||
$found = true;
|
||||
$detected += array_search($option, $this->constants);
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
$options['type'] = $detected;
|
||||
}
|
||||
if (! isset($options['type'])) {
|
||||
if (($type = $this->calculateTypeValue($options)) != 0) {
|
||||
$options['type'] = $type;
|
||||
} else {
|
||||
$options['type'] = $this->defaultType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,14 +137,14 @@ class NotEmpty extends AbstractValidator
|
||||
foreach ($type as $value) {
|
||||
if (is_int($value)) {
|
||||
$detected |= $value;
|
||||
} elseif (in_array($value, $this->constants)) {
|
||||
$detected |= array_search($value, $this->constants);
|
||||
} elseif (in_array($value, $this->constants, true)) {
|
||||
$detected |= array_search($value, $this->constants, true);
|
||||
}
|
||||
}
|
||||
|
||||
$type = $detected;
|
||||
} elseif (is_string($type) && in_array($type, $this->constants)) {
|
||||
$type = array_search($type, $this->constants);
|
||||
} elseif (is_string($type) && in_array($type, $this->constants, true)) {
|
||||
$type = array_search($type, $this->constants, true);
|
||||
}
|
||||
|
||||
return $type;
|
||||
@@ -172,7 +161,7 @@ class NotEmpty extends AbstractValidator
|
||||
{
|
||||
$type = $this->calculateTypeValue($type);
|
||||
|
||||
if (!is_int($type) || ($type < 0) || ($type > self::ALL)) {
|
||||
if (! is_int($type) || ($type < 0) || ($type > self::ALL)) {
|
||||
throw new Exception\InvalidArgumentException('Unknown type');
|
||||
}
|
||||
|
||||
@@ -189,8 +178,8 @@ class NotEmpty extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if ($value !== null && !is_string($value) && !is_int($value) && !is_float($value) &&
|
||||
!is_bool($value) && !is_array($value) && !is_object($value)
|
||||
if ($value !== null && ! is_string($value) && ! is_int($value) && ! is_float($value) &&
|
||||
! is_bool($value) && ! is_array($value) && ! is_object($value)
|
||||
) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
@@ -214,7 +203,7 @@ class NotEmpty extends AbstractValidator
|
||||
if ($type & self::OBJECT_STRING) {
|
||||
$object = true;
|
||||
|
||||
if ((is_object($value) && (!method_exists($value, '__toString'))) ||
|
||||
if ((is_object($value) && (! method_exists($value, '__toString'))) ||
|
||||
(is_object($value) && (method_exists($value, '__toString')) && (((string) $value) == ""))) {
|
||||
$this->error(self::IS_EMPTY);
|
||||
return false;
|
||||
|
@@ -45,7 +45,7 @@ class Regex extends AbstractValidator
|
||||
/**
|
||||
* Sets validator options
|
||||
*
|
||||
* @param string|Traversable $pattern
|
||||
* @param string|array|Traversable $pattern
|
||||
* @throws Exception\InvalidArgumentException On missing 'pattern' parameter
|
||||
*/
|
||||
public function __construct($pattern)
|
||||
@@ -60,11 +60,11 @@ class Regex extends AbstractValidator
|
||||
$pattern = ArrayUtils::iteratorToArray($pattern);
|
||||
}
|
||||
|
||||
if (!is_array($pattern)) {
|
||||
if (! is_array($pattern)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid options provided to constructor');
|
||||
}
|
||||
|
||||
if (!array_key_exists('pattern', $pattern)) {
|
||||
if (! array_key_exists('pattern', $pattern)) {
|
||||
throw new Exception\InvalidArgumentException("Missing option 'pattern'");
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ class Regex extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value) && !is_int($value) && !is_float($value)) {
|
||||
if (! is_string($value) && ! is_int($value) && ! is_float($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ class Regex extends AbstractValidator
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$status) {
|
||||
if (! $status) {
|
||||
$this->error(self::NOT_MATCH);
|
||||
return false;
|
||||
}
|
||||
|
@@ -55,17 +55,17 @@ class Changefreq extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setValue($value);
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($value, $this->changeFreqs, true)) {
|
||||
if (! in_array($value, $this->changeFreqs, true)) {
|
||||
$this->error(self::NOT_VALID);
|
||||
return false;
|
||||
}
|
||||
|
@@ -23,7 +23,9 @@ class Lastmod extends AbstractValidator
|
||||
* Regular expression to use when validating
|
||||
*
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
const LASTMOD_REGEX = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3])(:[0-5][0-9])(:[0-5][0-9])?(\\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])?$/';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* Validation key for not valid
|
||||
@@ -52,7 +54,7 @@ class Lastmod extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
@@ -48,14 +48,14 @@ class Loc extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setValue($value);
|
||||
$uri = Uri\UriFactory::factory($value);
|
||||
if (!$uri->isValid()) {
|
||||
if (! $uri->isValid()) {
|
||||
$this->error(self::NOT_VALID);
|
||||
return false;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ class Priority extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
if (! is_numeric($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
@@ -43,10 +43,10 @@ class Step extends AbstractValidator
|
||||
{
|
||||
if ($options instanceof Traversable) {
|
||||
$options = iterator_to_array($options);
|
||||
} elseif (!is_array($options)) {
|
||||
} elseif (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['baseValue'] = array_shift($options);
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['step'] = array_shift($options);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class Step extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
if (! is_numeric($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
@@ -31,14 +31,16 @@ class StringLength extends AbstractValidator
|
||||
* @var array
|
||||
*/
|
||||
protected $messageVariables = [
|
||||
'min' => ['options' => 'min'],
|
||||
'max' => ['options' => 'max'],
|
||||
'min' => ['options' => 'min'],
|
||||
'max' => ['options' => 'max'],
|
||||
'length' => ['options' => 'length']
|
||||
];
|
||||
|
||||
protected $options = [
|
||||
'min' => 0, // Minimum length
|
||||
'max' => null, // Maximum length, null if there is no length limitation
|
||||
'encoding' => 'UTF-8', // Encoding to use
|
||||
'length' => 0 // Actual length
|
||||
];
|
||||
|
||||
protected $stringWrapper;
|
||||
@@ -50,14 +52,14 @@ class StringLength extends AbstractValidator
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['min'] = array_shift($options);
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['max'] = array_shift($options);
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['encoding'] = array_shift($options);
|
||||
}
|
||||
|
||||
@@ -135,7 +137,7 @@ class StringLength extends AbstractValidator
|
||||
*/
|
||||
public function getStringWrapper()
|
||||
{
|
||||
if (!$this->stringWrapper) {
|
||||
if (! $this->stringWrapper) {
|
||||
$this->stringWrapper = StringUtils::getWrapper($this->getEncoding());
|
||||
}
|
||||
return $this->stringWrapper;
|
||||
@@ -177,6 +179,28 @@ class StringLength extends AbstractValidator
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length option
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getLength()
|
||||
{
|
||||
return $this->options['length'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the length option
|
||||
*
|
||||
* @param int $length
|
||||
* @return StringLength Provides a fluent interface
|
||||
*/
|
||||
private function setLength($length)
|
||||
{
|
||||
$this->options['length'] = (int) $length;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if the string length of $value is at least the min option and
|
||||
* no greater than the max option (when the max option is not null).
|
||||
@@ -186,19 +210,19 @@ class StringLength extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setValue($value);
|
||||
|
||||
$length = $this->getStringWrapper()->strlen($value);
|
||||
if ($length < $this->getMin()) {
|
||||
$this->setLength($this->getStringWrapper()->strlen($value));
|
||||
if ($this->getLength() < $this->getMin()) {
|
||||
$this->error(self::TOO_SHORT);
|
||||
}
|
||||
|
||||
if (null !== $this->getMax() && $this->getMax() < $length) {
|
||||
if (null !== $this->getMax() && $this->getMax() < $this->getLength()) {
|
||||
$this->error(self::TOO_LONG);
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ class Timezone extends AbstractValidator
|
||||
{
|
||||
$type = $this->calculateTypeValue($type);
|
||||
|
||||
if (!is_int($type) || ($type < 1) || ($type > self::ALL)) {
|
||||
if (! is_int($type) || ($type < 1) || ($type > self::ALL)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Unknown type "%s" provided',
|
||||
(is_string($type) || is_int($type))
|
||||
@@ -107,7 +107,7 @@ class Timezone extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if ($value !== null && !is_string($value)) {
|
||||
if ($value !== null && ! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class Timezone extends AbstractValidator
|
||||
$abbrs = DateTimeZone::listAbbreviations();
|
||||
$locations = DateTimeZone::listIdentifiers();
|
||||
|
||||
if (!array_key_exists($value, $abbrs) && !in_array($value, $locations)) {
|
||||
if (! array_key_exists($value, $abbrs) && ! in_array($value, $locations)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ class Timezone extends AbstractValidator
|
||||
case ($type & self::LOCATION):
|
||||
$locations = DateTimeZone::listIdentifiers();
|
||||
|
||||
if (!in_array($value, $locations)) {
|
||||
if (! in_array($value, $locations)) {
|
||||
$this->error(self::INVALID_TIMEZONE_LOCATION);
|
||||
return false;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ class Timezone extends AbstractValidator
|
||||
case ($type & self::ABBREVIATION):
|
||||
$abbrs = DateTimeZone::listAbbreviations();
|
||||
|
||||
if (!array_key_exists($value, $abbrs)) {
|
||||
if (! array_key_exists($value, $abbrs)) {
|
||||
$this->error(self::INVALID_TIMEZONE_ABBREVIATION);
|
||||
return false;
|
||||
}
|
||||
|
@@ -51,13 +51,13 @@ class Uri extends AbstractValidator
|
||||
{
|
||||
if ($options instanceof Traversable) {
|
||||
$options = iterator_to_array($options);
|
||||
} elseif (!is_array($options)) {
|
||||
} elseif (! is_array($options)) {
|
||||
$options = func_get_args();
|
||||
$temp['uriHandler'] = array_shift($options);
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['allowRelative'] = array_shift($options);
|
||||
}
|
||||
if (!empty($options)) {
|
||||
if (! empty($options)) {
|
||||
$temp['allowAbsolute'] = array_shift($options);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ class Uri extends AbstractValidator
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if (! is_string($value)) {
|
||||
$this->error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ class ValidatorChain implements
|
||||
*/
|
||||
public function getPluginManager()
|
||||
{
|
||||
if (!$this->plugins) {
|
||||
if (! $this->plugins) {
|
||||
$this->setPluginManager(new ValidatorPluginManager(new ServiceManager));
|
||||
}
|
||||
return $this->plugins;
|
||||
@@ -137,8 +137,11 @@ class ValidatorChain implements
|
||||
* @param int $priority
|
||||
* @return ValidatorChain Provides a fluent interface
|
||||
*/
|
||||
public function addValidator(ValidatorInterface $validator, $breakChainOnFailure = false, $priority = self::DEFAULT_PRIORITY)
|
||||
{
|
||||
public function addValidator(
|
||||
ValidatorInterface $validator,
|
||||
$breakChainOnFailure = false,
|
||||
$priority = self::DEFAULT_PRIORITY
|
||||
) {
|
||||
return $this->attach($validator, $breakChainOnFailure, $priority);
|
||||
}
|
||||
|
||||
@@ -156,7 +159,7 @@ class ValidatorChain implements
|
||||
{
|
||||
$priority = self::DEFAULT_PRIORITY;
|
||||
|
||||
if (!$this->validators->isEmpty()) {
|
||||
if (! $this->validators->isEmpty()) {
|
||||
$extractedNodes = $this->validators->toArray(PriorityQueue::EXTR_PRIORITY);
|
||||
rsort($extractedNodes, SORT_NUMERIC);
|
||||
$priority = $extractedNodes[0] + 1;
|
||||
|
@@ -120,6 +120,9 @@ class ValidatorPluginManager extends AbstractPluginManager
|
||||
'FileWordCount' => File\WordCount::class,
|
||||
'float' => I18nValidator\IsFloat::class,
|
||||
'Float' => I18nValidator\IsFloat::class,
|
||||
'gpspoint' => GpsPoint::class,
|
||||
'gpsPoint' => GpsPoint::class,
|
||||
'GpsPoint' => GpsPoint::class,
|
||||
'greaterthan' => GreaterThan::class,
|
||||
'greaterThan' => GreaterThan::class,
|
||||
'GreaterThan' => GreaterThan::class,
|
||||
@@ -184,6 +187,8 @@ class ValidatorPluginManager extends AbstractPluginManager
|
||||
'Timezone' => Timezone::class,
|
||||
'uri' => Uri::class,
|
||||
'Uri' => Uri::class,
|
||||
'uuid' => Uuid::class,
|
||||
'Uuid' => Uuid::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -228,6 +233,7 @@ class ValidatorPluginManager extends AbstractPluginManager
|
||||
File\UploadFile::class => InvokableFactory::class,
|
||||
File\WordCount::class => InvokableFactory::class,
|
||||
I18nValidator\IsFloat::class => InvokableFactory::class,
|
||||
GpsPoint::class => InvokableFactory::class,
|
||||
GreaterThan::class => InvokableFactory::class,
|
||||
Hex::class => InvokableFactory::class,
|
||||
Hostname::class => InvokableFactory::class,
|
||||
@@ -253,6 +259,7 @@ class ValidatorPluginManager extends AbstractPluginManager
|
||||
Step::class => InvokableFactory::class,
|
||||
Timezone::class => InvokableFactory::class,
|
||||
Uri::class => InvokableFactory::class,
|
||||
Uuid::class => InvokableFactory::class,
|
||||
|
||||
// v2 canonical FQCNs
|
||||
|
||||
@@ -315,6 +322,7 @@ class ValidatorPluginManager extends AbstractPluginManager
|
||||
'zendvalidatorfileupload' => InvokableFactory::class,
|
||||
'zendvalidatorfileuploadfile' => InvokableFactory::class,
|
||||
'zendvalidatorfilewordcount' => InvokableFactory::class,
|
||||
'zendvalidatorgpspoint' => InvokableFactory::class,
|
||||
'zendvalidatorgreaterthan' => InvokableFactory::class,
|
||||
'zendvalidatorhex' => InvokableFactory::class,
|
||||
'zendvalidatorhostname' => InvokableFactory::class,
|
||||
@@ -323,8 +331,6 @@ class ValidatorPluginManager extends AbstractPluginManager
|
||||
'zendi18nvalidatordatetime' => InvokableFactory::class,
|
||||
'zendi18nvalidatorisfloat' => InvokableFactory::class,
|
||||
'zendi18nvalidatorisint' => InvokableFactory::class,
|
||||
'zendi18nvalidatorisfloat' => InvokableFactory::class,
|
||||
'zendi18nvalidatorisint' => InvokableFactory::class,
|
||||
'zendi18nvalidatorphonenumber' => InvokableFactory::class,
|
||||
'zendi18nvalidatorpostcode' => InvokableFactory::class,
|
||||
'zendvalidatoriban' => InvokableFactory::class,
|
||||
@@ -344,6 +350,7 @@ class ValidatorPluginManager extends AbstractPluginManager
|
||||
'zendvalidatorstep' => InvokableFactory::class,
|
||||
'zendvalidatortimezone' => InvokableFactory::class,
|
||||
'zendvalidatoruri' => InvokableFactory::class,
|
||||
'zendvalidatoruuid' => InvokableFactory::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@@ -8,6 +8,7 @@
|
||||
namespace Zend\Validator;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\ServiceManager\Config;
|
||||
use Zend\ServiceManager\FactoryInterface;
|
||||
use Zend\ServiceManager\ServiceLocatorInterface;
|
||||
|
||||
@@ -27,7 +28,30 @@ class ValidatorPluginManagerFactory implements FactoryInterface
|
||||
*/
|
||||
public function __invoke(ContainerInterface $container, $name, array $options = null)
|
||||
{
|
||||
return new ValidatorPluginManager($container, $options ?: []);
|
||||
$pluginManager = new ValidatorPluginManager($container, $options ?: []);
|
||||
|
||||
// If this is in a zend-mvc application, the ServiceListener will inject
|
||||
// merged configuration during bootstrap.
|
||||
if ($container->has('ServiceListener')) {
|
||||
return $pluginManager;
|
||||
}
|
||||
|
||||
// If we do not have a config service, nothing more to do
|
||||
if (! $container->has('config')) {
|
||||
return $pluginManager;
|
||||
}
|
||||
|
||||
$config = $container->get('config');
|
||||
|
||||
// If we do not have validators configuration, nothing more to do
|
||||
if (! isset($config['validators']) || ! is_array($config['validators'])) {
|
||||
return $pluginManager;
|
||||
}
|
||||
|
||||
// Wire service configuration for validators
|
||||
(new Config($config['validators']))->configureServiceManager($pluginManager);
|
||||
|
||||
return $pluginManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user