@@ -119,15 +119,10 @@ exports.process = function (errors, object) {
119
119
return item . options . error ;
120
120
}
121
121
122
- const detail = {
123
- message : item . toString ( ) ,
124
- path : internals . getPath ( item ) ,
125
- type : item . type ,
126
- context : item . context
127
- } ;
128
-
122
+ let itemMessage ;
129
123
if ( parent === undefined ) {
130
- message = message + ( message ? '. ' : '' ) + detail . message ;
124
+ itemMessage = item . toString ( ) ;
125
+ message = message + ( message ? '. ' : '' ) + itemMessage ;
131
126
}
132
127
133
128
// Do not push intermediate errors, we're only interested in leafs
@@ -139,7 +134,12 @@ exports.process = function (errors, object) {
139
134
}
140
135
}
141
136
else {
142
- details . push ( detail ) ;
137
+ details . push ( {
138
+ message : itemMessage || item . toString ( ) ,
139
+ path : internals . getPath ( item ) ,
140
+ type : item . type ,
141
+ context : item . context
142
+ } ) ;
143
143
}
144
144
}
145
145
} ;
@@ -161,17 +161,7 @@ exports.process = function (errors, object) {
161
161
162
162
internals . getPath = function ( item ) {
163
163
164
- const recursePath = ( it ) => {
165
-
166
- const reachedItem = Hoek . reach ( it , 'context.reason.0' ) ;
167
- if ( reachedItem && reachedItem . context ) {
168
- return recursePath ( reachedItem ) ;
169
- }
170
-
171
- return it . path ;
172
- } ;
173
-
174
- return recursePath ( item ) || item . context . key ;
164
+ return item . path || item . context . key ;
175
165
} ;
176
166
177
167
0 commit comments