Skip to content

Commit 87ee2a5

Browse files
committed
add tests for fix: #20
1 parent faf3eed commit 87ee2a5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/RuleValidationTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,39 @@ public function testIssues17(): void
724724
$this->assertSame('xxx error', $v->firstError());
725725
}
726726

727+
/**
728+
* @link https://github.com/inhere/php-validate/issues/20
729+
*/
730+
public function testIssues20(): void
731+
{
732+
$d = [
733+
'product' => [
734+
[
735+
'sku_id' => 1,
736+
'properties' => 'aaa'
737+
],
738+
[
739+
'sku_id' => 2,
740+
'properties' => 'bbb'
741+
]
742+
]
743+
];
744+
$r = [
745+
['product.*.properties', 'each', 'string', 'max' => 40],
746+
];
747+
748+
$v = RV::check($d, $r);
749+
$this->assertTrue($v->isOk());
750+
751+
$r = [
752+
['product.*.properties', 'each', 'string', 'max' => 2],
753+
];
754+
755+
$v = RV::check($d, $r);
756+
$this->assertFalse($v->isOk());
757+
$this->assertSame('product.*.properties each value must be through the "string" verify', $v->firstError());
758+
}
759+
727760
/**
728761
* @link https://github.com/inhere/php-validate/issues/21
729762
*/

0 commit comments

Comments
 (0)