Skip to content

Commit

Permalink
Merge branch '1.0' into 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquemoody committed Mar 14, 2017
2 parents 03f4abb + dc869ac commit 5ab87d1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function ($match) use ($vars) {
}

$value = $vars[$match[1]];
if ('name' == $match[1]) {
if ('name' == $match[1] && is_string($value)) {
return $value;
}

Expand Down
46 changes: 46 additions & 0 deletions tests/integration/issue-799.phpt
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 5ab87d1

Please sign in to comment.