Skip to content

Commit 2077414

Browse files
fix: add test rules for array in required_with and required_without
see #3966 (comment)
1 parent 6b4221a commit 2077414

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

tests/system/Validation/RulesTest.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ public function testRequiredWith($field, $check, $expected = false)
14991499
'foo' => 'bar',
15001500
'bar' => 'something',
15011501
'baz' => null,
1502-
'ar' => [],// Was running into issues with array values
1502+
'array' => ['nonEmptyField1'=>'value1','nonEmptyField2'=>'value2', 'emptyField1'=>null, 'emptyField2'=>null],
15031503
];
15041504

15051505
$this->validation->setRules([
@@ -1544,6 +1544,26 @@ public function requiredWithProvider()
15441544
null,
15451545
true,
15461546
],
1547+
[
1548+
'array.emptyField1',
1549+
'array.emptyField2',
1550+
true,
1551+
],
1552+
[
1553+
'array.nonEmptyField1',
1554+
'array.emptyField2',
1555+
true,
1556+
],
1557+
[
1558+
'array.emptyField1',
1559+
'array.nonEmptyField2',
1560+
false,
1561+
],
1562+
[
1563+
'array.nonEmptyField1',
1564+
'array.nonEmptyField2',
1565+
true,
1566+
],
15471567
];
15481568
}
15491569

@@ -1561,6 +1581,7 @@ public function testRequiredWithout($field, $check, $expected = false)
15611581
'foo' => 'bar',
15621582
'bar' => 'something',
15631583
'baz' => null,
1584+
'array' => ['nonEmptyField1'=>'value1','nonEmptyField2'=>'value2', 'emptyField1'=>null, 'emptyField2'=>null],
15641585
];
15651586

15661587
$this->validation->setRules([
@@ -1600,6 +1621,26 @@ public function requiredWithoutProvider()
16001621
null,
16011622
true,
16021623
],
1624+
[
1625+
'array.emptyField1',
1626+
'array.emptyField2',
1627+
false,
1628+
],
1629+
[
1630+
'array.nonEmptyField1',
1631+
'array.emptyField2',
1632+
true,
1633+
],
1634+
[
1635+
'array.emptyField1',
1636+
'array.nonEmptyField2',
1637+
true,
1638+
],
1639+
[
1640+
'array.nonEmptyField1',
1641+
'array.nonEmptyField2',
1642+
true,
1643+
],
16031644
];
16041645
}
16051646

0 commit comments

Comments
 (0)