mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Merge pull request #350 from eugene-borovov/requirewith-dot-notation
Added dot notation to requireWith(out)
This commit is contained in:
commit
0cbc5834b0
@ -971,8 +971,8 @@ class Validator
|
|||||||
$emptyFields = 0;
|
$emptyFields = 0;
|
||||||
foreach ($reqParams as $requiredField) {
|
foreach ($reqParams as $requiredField) {
|
||||||
// check the field is set, not null, and not the empty string
|
// check the field is set, not null, and not the empty string
|
||||||
if (isset($fields[$requiredField]) && !is_null($fields[$requiredField])
|
list($requiredFieldValue, $multiple) = $this->getPart($fields, explode('.', $requiredField));
|
||||||
&& (is_string($fields[$requiredField]) ? trim($fields[$requiredField]) !== '' : true)) {
|
if (isset($requiredFieldValue) && (!is_string($requiredFieldValue) || trim($requiredFieldValue) !== '')) {
|
||||||
if (!$allRequired) {
|
if (!$allRequired) {
|
||||||
$conditionallyReq = true;
|
$conditionallyReq = true;
|
||||||
break;
|
break;
|
||||||
@ -1015,8 +1015,8 @@ class Validator
|
|||||||
$filledFields = 0;
|
$filledFields = 0;
|
||||||
foreach ($reqParams as $requiredField) {
|
foreach ($reqParams as $requiredField) {
|
||||||
// check the field is NOT set, null, or the empty string, in which case we are requiring this value be present
|
// check the field is NOT set, null, or the empty string, in which case we are requiring this value be present
|
||||||
if (!isset($fields[$requiredField]) || (is_null($fields[$requiredField])
|
list($requiredFieldValue, $multiple) = $this->getPart($fields, explode('.', $requiredField));
|
||||||
|| (is_string($fields[$requiredField]) && trim($fields[$requiredField]) === ''))) {
|
if (!isset($requiredFieldValue) || (is_string($requiredFieldValue) && trim($requiredFieldValue) === '')) {
|
||||||
if (!$allEmpty) {
|
if (!$allEmpty) {
|
||||||
$conditionallyReq = true;
|
$conditionallyReq = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user