Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix Validator's checkCanString behaviour
  • Loading branch information
MaxKlyukin committed Sep 28, 2015
1 parent 1d0d9b0 commit 111770f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Api/Validator.php
Expand Up @@ -212,7 +212,7 @@ private function checkCanString($value)
$type = gettype($value);

return isset($valid[$type]) ||
($type == 'object' && method_exists($valid, '__toString'));
($type == 'object' && method_exists($value, '__toString'));
}

private function checkAssociativeArray($value)
Expand Down
11 changes: 11 additions & 0 deletions tests/Api/Stringable.php
@@ -0,0 +1,11 @@
<?php

namespace Aws\Test\Api;

class Stringable
{
public function __toString()
{
return 'Hello world';
}
}
8 changes: 8 additions & 0 deletions tests/Api/ValidatorTest.php
Expand Up @@ -341,6 +341,14 @@ public function validationProvider()
. "[foo] must have at least 10 members. Value provided has 2.\n"
. "[foo] must have no more than 1 members. Value provided has 2."
],
[
[
'type' => 'structure',
'members' => ['foo' => ['type' => 'string']]
],
['foo' => new Stringable()],
true
],
];
}

Expand Down

0 comments on commit 111770f

Please sign in to comment.