mirror of
https://github.com/Respect/Validation.git
synced 2024-06-27 09:40:05 +02:00
Merge branch '0.9'
This commit is contained in:
commit
2c2c838c1a
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ class JsonTest extends \PHPUnit_Framework_TestCase
|
|||
array('[1,2,3]'),
|
||||
array('["foo", "bar", "number", 1]'),
|
||||
array('{"foo": "bar", "number":1}'),
|
||||
array('[]'),
|
||||
array('{}'),
|
||||
array('false'),
|
||||
array('null'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue