Merge branch '1.1'

This commit is contained in:
Henrique Moody 2017-03-14 10:46:47 +01:00
commit 2b8c560db4
No known key found for this signature in database
GPG key ID: 221E9281655813A6
2 changed files with 47 additions and 1 deletions

View file

@ -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;
}

View 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"