@@ -101,7 +101,7 @@ protected function parseSessionValidationErrors(Request $request, BaseResponse $
101
101
102
102
// TODO test this
103
103
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 }" )
105
105
);
106
106
}
107
107
@@ -118,12 +118,12 @@ protected function parseJsonValidationErrors(Request $request, BaseResponse $res
118
118
! is_array ($ response ->original ) ||
119
119
! array_key_exists ('errors ' , $ response ->original ) ||
120
120
! is_array ($ response ->original ['errors ' ]) ||
121
- array_is_list ($ response ->original ['errors ' ])
121
+ array_is_list ($ errors = $ response ->original ['errors ' ])
122
122
) {
123
123
return null ;
124
124
}
125
125
126
- return collect ($ response -> original [ ' errors ' ] )->keys ();
126
+ return collect ($ errors )->keys ();
127
127
}
128
128
129
129
/**
@@ -140,13 +140,19 @@ protected function parseInertiaValidationErrors(Request $request, BaseResponse $
140
140
! array_key_exists ('props ' , $ response ->original ) ||
141
141
! is_array ($ response ->original ['props ' ]) ||
142
142
! array_key_exists ('errors ' , $ response ->original ['props ' ]) ||
143
- ! $ response ->original ['props ' ]['errors ' ] instanceof stdClass
143
+ ! ( $ errors = $ response ->original ['props ' ]['errors ' ]) instanceof stdClass
144
144
) {
145
145
return null ;
146
146
}
147
147
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
+ );
150
156
}
151
157
152
158
/**
0 commit comments