Merge pull request #350 from eugene-borovov/requirewith-dot-notation

Added dot notation to requireWith(out)
This commit is contained in:
Willem Wollebrants 2022-10-14 13:52:03 +02:00 committed by GitHub
commit 0cbc5834b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;