Skip to content

Commit 948fd96

Browse files
authored
Merge pull request #336 from Wixel/fix-328
Fixes #328
2 parents 2e5ba48 + 63b1d0b commit 948fd96

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Diff for: gump.class.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -1887,11 +1887,9 @@ protected function validate_regex($field, array $input, array $params = [], $val
18871887
*/
18881888
protected function validate_valid_json_string($field, array $input, array $params = [], $value = null)
18891889
{
1890-
if (!is_string($input[$field]) || !is_object(json_decode($value))) {
1891-
return false;
1892-
}
1893-
1894-
return true;
1890+
return is_string($input[$field])
1891+
&& is_array(json_decode($value, true))
1892+
&& (json_last_error() == JSON_ERROR_NONE);
18951893
}
18961894

18971895
/**

Diff for: tests/Validators/ValidJsonStringValidatorTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function successProvider()
2828
return [
2929
['{}'],
3030
['{"testing": true}'],
31+
['["one", "two"]'],
3132
];
3233
}
3334

@@ -52,4 +53,4 @@ public function testWhenInputIsEmptyAndNotRequiredIsSuccess()
5253
{
5354
$this->assertTrue($this->validate(self::RULE, ''));
5455
}
55-
}
56+
}

0 commit comments

Comments
 (0)