Navigation Menu

Skip to content

Commit

Permalink
Merge branch '0.8' into 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquemoody committed May 28, 2015
2 parents fc08c96 + abc712d commit d0f36de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/Rules/Json.php
Expand Up @@ -5,6 +5,11 @@ class Json extends AbstractRule
{
public function validate($input)
{
return (bool) (json_decode($input));
if (is_string($input)
&& strtolower($input) == 'null') {
return true;
}

return (null !== json_decode($input));
}
}
4 changes: 4 additions & 0 deletions tests/Rules/JsonTest.php
Expand Up @@ -38,6 +38,10 @@ public function providerForPass()
array('[1,2,3]'),
array('["foo", "bar", "number", 1]'),
array('{"foo": "bar", "number":1}'),
array('[]'),
array('{}'),
array('false'),
array('null'),
);
}

Expand Down

0 comments on commit d0f36de

Please sign in to comment.