@@ -198,11 +198,15 @@ protected function processRules(string $field, ?string $label, $value, $rules =
198198 // that can be used later
199199 $ ifExistField = str_replace ('\.\* ' , '\.(?:[^\.]+) ' , preg_quote ($ field , '/ ' ));
200200
201- $ dataIsExisting = array_reduce (array_keys ($ flattenedData ), static function ($ carry , $ item ) use ($ ifExistField ) {
202- $ pattern = sprintf ('/%s/u ' , $ ifExistField );
203-
204- return $ carry || preg_match ($ pattern , $ item ) === 1 ;
205- }, false );
201+ $ dataIsExisting = array_reduce (
202+ array_keys ($ flattenedData ),
203+ static function ($ carry , $ item ) use ($ ifExistField ) {
204+ $ pattern = sprintf ('/%s/u ' , $ ifExistField );
205+
206+ return $ carry || preg_match ($ pattern , $ item ) === 1 ;
207+ },
208+ false
209+ );
206210 } else {
207211 $ dataIsExisting = array_key_exists ($ ifExistField , $ flattenedData );
208212 }
@@ -219,7 +223,10 @@ protected function processRules(string $field, ?string $label, $value, $rules =
219223 }
220224
221225 if (in_array ('permit_empty ' , $ rules , true )) {
222- if (! in_array ('required ' , $ rules , true ) && (is_array ($ value ) ? $ value === [] : trim ((string ) $ value ) === '' )) {
226+ if (
227+ ! in_array ('required ' , $ rules , true )
228+ && (is_array ($ value ) ? $ value === [] : trim ((string ) $ value ) === '' )
229+ ) {
223230 $ passed = true ;
224231
225232 foreach ($ rules as $ rule ) {
@@ -278,7 +285,8 @@ protected function processRules(string $field, ?string $label, $value, $rules =
278285 }
279286
280287 $ found = true ;
281- $ passed = $ param === false ? $ set ->{$ rule }($ value , $ error ) : $ set ->{$ rule }($ value , $ param , $ data , $ error );
288+ $ passed = $ param === false ? $ set ->{$ rule }($ value , $ error )
289+ : $ set ->{$ rule }($ value , $ param , $ data , $ error );
282290
283291 break ;
284292 }
@@ -300,7 +308,13 @@ protected function processRules(string $field, ?string $label, $value, $rules =
300308 }
301309
302310 $ param = ($ param === false ) ? '' : $ param ;
303- $ this ->errors [$ field ] = $ error ?? $ this ->getErrorMessage ($ rule , $ field , $ label , $ param , (string ) $ value );
311+ $ this ->errors [$ field ] = $ error ?? $ this ->getErrorMessage (
312+ $ rule ,
313+ $ field ,
314+ $ label ,
315+ $ param ,
316+ (string ) $ value
317+ );
304318
305319 return false ;
306320 }
@@ -664,7 +678,11 @@ protected function getErrorMessage(string $rule, string $field, ?string $label =
664678 }
665679
666680 $ message = str_replace ('{field} ' , empty ($ label ) ? $ field : lang ($ label ), $ message );
667- $ message = str_replace ('{param} ' , empty ($ this ->rules [$ param ]['label ' ]) ? $ param : lang ($ this ->rules [$ param ]['label ' ]), $ message );
681+ $ message = str_replace (
682+ '{param} ' ,
683+ empty ($ this ->rules [$ param ]['label ' ]) ? $ param : lang ($ this ->rules [$ param ]['label ' ]),
684+ $ message
685+ );
668686
669687 return str_replace ('{value} ' , $ value ?? '' , $ message );
670688 }
0 commit comments