Skip to content

Commit

Permalink
Added infinities for ArrayS
Browse files Browse the repository at this point in the history
  • Loading branch information
3nr1c committed Jul 27, 2015
1 parent 0abccc3 commit 02dcb9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Structure/ArrayS.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected function checkFormat($data = null) {
* @throws \Exception
*/
protected function checkValue($data, $format, $applyFormat = false) {
$numeric = '/^(numeric|float|integer|int)(\(|\[)-?\d+(\.\d+)?,-?\d+(\.\d+)?(\)|\])$/';
$numeric = '/^(numeric|float|integer|int)(\(|\[).+,.+(\)|\])$/';
$valueSetScalar = '/^(scalar|string|float|integer|int|str|boolean|bool|numeric)\{[^}]*\}$/';

if (is_null($data)) {
Expand Down
10 changes: 10 additions & 0 deletions tests/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,14 @@ public function testValueSets2() {
}
}
}

public function testInfinities() {
$format = array(
"foo" => "numeric(0, +inf)"
);
$array = \Structure\Structure::ArrayS($format);
$this->assertTrue($array->check(array("foo" => "3")));
$this->assertFalse($array->check(array("foo" => "-1")));
$this->assertFalse($array->check(array("foo" => "0")));
}
}

0 comments on commit 02dcb9c

Please sign in to comment.