@@ -282,8 +282,8 @@ public function required_with($str = null, ?string $fields = null, array $data =
282282 */
283283 public function required_without ($ str = null , ?string $ fields = null , array $ data = [], ?string $ error = null , ?string $ keyField = null ): bool
284284 {
285- if ($ fields === null || empty ($ data ) || $ keyField === null ) {
286- throw new InvalidArgumentException ('You must supply the parameters: fields, data, keyField. ' );
285+ if ($ fields === null || empty ($ data )) {
286+ throw new InvalidArgumentException ('You must supply the parameters: fields, data ' );
287287 }
288288
289289 // If the field is present we can safely assume that
@@ -298,19 +298,21 @@ public function required_without($str = null, ?string $fields = null, array $dat
298298
299299 $ nowKeyField = 0 ;
300300
301- if (strpos ($ keyField , '. ' ) !== false ) {
302- $ keyFieldArray = explode ('. ' , $ keyField );
303- $ nowKeyField = $ keyFieldArray [1 ];
304- }
305-
306301 // Still here? Then we fail this test if
307302 // any of the fields are not present in $data
308303 foreach ($ fields as $ field ) {
309304 if ((strpos ($ field , '. ' ) === false ) && (! array_key_exists ($ field , $ data ))) {
310305 return ! empty ($ data [$ field ]);
311306 }
312307 if (strpos ($ field , '. ' ) !== false ) {
313- $ fieldData = dot_array_search ($ field , $ data );
308+ if ($ keyField == null ) {
309+ throw new InvalidArgumentException ('You must supply the parameters: keyField ' );
310+ }
311+
312+ $ fieldData = dot_array_search ($ field , $ data );
313+ $ keyFieldArray = explode ('. ' , $ keyField );
314+ $ nowKeyField = $ keyFieldArray [1 ];
315+
314316 if (is_array ($ fieldData )) {
315317 return ! empty (dot_array_search ($ field , $ data )[$ nowKeyField ]);
316318 }
0 commit comments