@@ -101,7 +101,7 @@ protected function parseSessionValidationErrors(Request $request, BaseResponse $
101101
102102 // TODO test this
103103 return collect ($ bags )->flatMap (
104- fn ($ bag , $ bagName ) => collect ($ bags [ 0 ] ->keys ())->map (fn ($ inputName ) => "{$ bagName }: {$ inputName }" )
104+ fn ($ bag , $ bagName ) => collect ($ bag ->keys ())->map (fn ($ inputName ) => "{$ bagName }: {$ inputName }" )
105105 );
106106 }
107107
@@ -118,12 +118,12 @@ protected function parseJsonValidationErrors(Request $request, BaseResponse $res
118118 ! is_array ($ response ->original ) ||
119119 ! array_key_exists ('errors ' , $ response ->original ) ||
120120 ! is_array ($ response ->original ['errors ' ]) ||
121- array_is_list ($ response ->original ['errors ' ])
121+ array_is_list ($ errors = $ response ->original ['errors ' ])
122122 ) {
123123 return null ;
124124 }
125125
126- return collect ($ response -> original [ ' errors ' ] )->keys ();
126+ return collect ($ errors )->keys ();
127127 }
128128
129129 /**
@@ -140,13 +140,19 @@ protected function parseInertiaValidationErrors(Request $request, BaseResponse $
140140 ! array_key_exists ('props ' , $ response ->original ) ||
141141 ! is_array ($ response ->original ['props ' ]) ||
142142 ! array_key_exists ('errors ' , $ response ->original ['props ' ]) ||
143- ! $ response ->original ['props ' ]['errors ' ] instanceof stdClass
143+ ! ( $ errors = $ response ->original ['props ' ]['errors ' ]) instanceof stdClass
144144 ) {
145145 return null ;
146146 }
147147
148- // TODO error bags
149- return collect ($ response ->original ['props ' ]['errors ' ])->keys ();
148+ if (is_string (($ errors = collect ($ errors ))->first ())) {
149+ return $ errors ->keys ();
150+ }
151+
152+ // TODO test this
153+ return $ errors ->flatMap (
154+ fn ($ bag , $ bagName ) => collect ($ bag )->keys ()->map (fn ($ inputName ) => "{$ bagName }: {$ inputName }" )
155+ );
150156 }
151157
152158 /**
0 commit comments