mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 06:12:17 +02:00
Merge branch '1.1'
This commit is contained in:
commit
2b8c560db4
|
@ -62,7 +62,7 @@ class ValidationException extends InvalidArgumentException implements ExceptionI
|
|||
}
|
||||
|
||||
$value = $vars[$match[1]];
|
||||
if ('name' == $match[1]) {
|
||||
if ('name' == $match[1] && is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
46
tests/integration/issue-799.phpt
Normal file
46
tests/integration/issue-799.phpt
Normal file
|
@ -0,0 +1,46 @@
|
|||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
class MyClass
|
||||
{
|
||||
public function parse($url)
|
||||
{
|
||||
return parse_url($url);
|
||||
}
|
||||
}
|
||||
|
||||
$input = 'http://www.google.com/search?q=respect.github.com';
|
||||
|
||||
try {
|
||||
v::create()
|
||||
->call(
|
||||
[new MyClass(), 'parse'],
|
||||
v::arrayVal()->key('scheme', v::startsWith('https'))
|
||||
)
|
||||
->assert($input);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getMainMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::create()
|
||||
->call(
|
||||
function($url) {
|
||||
return parse_url($url);
|
||||
},
|
||||
v::arrayVal()->key('scheme', v::startsWith('https'))
|
||||
)
|
||||
->assert($input);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getMainMessage().PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
All of the required rules must pass for "http://www.google.com/search?q=respect.github.com"
|
||||
All of the required rules must pass for "http://www.google.com/search?q=respect.github.com"
|
Loading…
Reference in a new issue