File tree Expand file tree Collapse file tree 4 files changed +2733
-1969
lines changed Expand file tree Collapse file tree 4 files changed +2733
-1969
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ try {
191191{
192192 "statusCode" : 400 ,
193193 "error" : " Bad Request" ,
194- "message" : " <ul class=\" text-xs- left mb-0\" ><li>Path `company_logo` is required.</li><li>Gig description must be 100-300 characters.</li></ul>"
194+ "message" : " <ul class=\" text-left mb-0\" ><li>Path `company_logo` is required.</li><li>Gig description must be 100-300 characters.</li></ul>"
195195}
196196```
197197
Original file line number Diff line number Diff line change 99 " @commitlint/config-conventional"
1010 ]
1111 },
12+ "contributors" : [
13+ 14+ ],
1215 "dependencies" : {
1316 "boom" : " 5.1.0" ,
1417 "co" : " ^4.6.0" ,
1518 "debug" : " ^4.1.1" ,
16- "lodash" : " ^4.17.11 " ,
19+ "lodash" : " ^4.17.15 " ,
1720 "underscore.string" : " ^3.3.5"
1821 },
1922 "devDependencies" : {
20- "@commitlint/cli" : " ^7.5.2 " ,
21- "@commitlint/config-conventional" : " ^7.5 .0" ,
22- "ava" : " ^1.4 .0" ,
23+ "@commitlint/cli" : " ^8.1.0 " ,
24+ "@commitlint/config-conventional" : " ^8.1 .0" ,
25+ "ava" : " ^2.3 .0" ,
2326 "babel-cli" : " ^6.26.0" ,
2427 "babel-preset-env" : " ^1.7.0" ,
25- "codecov" : " ^3.2 .0" ,
26- "cross-env" : " ^5.2.0 " ,
27- "eslint" : " ^5.15.3 " ,
28+ "codecov" : " ^3.5 .0" ,
29+ "cross-env" : " ^5.2.1 " ,
30+ "eslint" : " ^6.3.0 " ,
2831 "eslint-config-xo-lass" : " ^1.0.3" ,
2932 "fixpack" : " ^2.3.1" ,
30- "husky" : " ^1.3.1 " ,
31- "koa" : " ^2.7.0 " ,
33+ "husky" : " ^3.0.5 " ,
34+ "koa" : " ^2.8.1 " ,
3235 "koa-404-handler" : " ^0.0.2" ,
3336 "koa-basic-auth" : " https://github.com/niftylettuce/basic-auth" ,
3437 "koa-connect-flash" : " ^0.1.2" ,
3538 "koa-convert" : " ^1.2.0" ,
3639 "koa-generic-session" : " ^2.0.1" ,
37- "koa-redis" : " ^3.1.3 " ,
40+ "koa-redis" : " ^4.0.0 " ,
3841 "koa-router" : " ^7.4.0" ,
39- "lint-staged" : " ^8.1 .5" ,
40- "nyc" : " ^13.3.0 " ,
42+ "lint-staged" : " ^9.2 .5" ,
43+ "nyc" : " ^14.1.1 " ,
4144 "redis" : " ^2.8.0" ,
42- "remark-cli" : " ^6 .0.1 " ,
43- "remark-preset-github" : " ^0.0.13 " ,
45+ "remark-cli" : " ^7 .0.0 " ,
46+ "remark-preset-github" : " ^0.0.16 " ,
4447 "supertest" : " ^4.0.2" ,
4548 "xo" : " ^0.24.0"
4649 },
Original file line number Diff line number Diff line change @@ -221,19 +221,25 @@ function parseValidationError(ctx, err) {
221221 return error ;
222222 } ) ;
223223
224+ // translate messages
225+ const translate = message =>
226+ _ . isFunction ( ctx . request . t ) ? ctx . request . t ( message ) : message ;
227+
224228 // loop over the errors object of the Validation Error
225229 // with support for HTML error lists
226230 if ( _ . values ( err . errors ) . length === 1 ) {
227- err . message = _ . values ( err . errors ) [ 0 ] . message ;
231+ err . message = translate ( _ . values ( err . errors ) [ 0 ] . message ) ;
228232 } else {
229- const errors = _ . map ( _ . values ( err . errors ) , 'message' ) ;
233+ const errors = _ . map ( _ . map ( _ . values ( err . errors ) , 'message' ) , translate ) ;
230234 err . message = ctx . api
231235 ? errors . join ( ', ' )
232- : `<ul class="text-xs-left mb-0"><li>${ errors . join (
233- '</li><li>'
234- ) } </li></ul>`;
236+ : `<ul class="text-left mb-0"><li>${ errors . join ( '</li><li>' ) } </li></ul>` ;
235237 }
236238
239+ // this ensures the error shows up client-side
240+ err . status = 400 ;
241+ err . statusCode = 400 ;
242+
237243 return err ;
238244}
239245
You can’t perform that action at this time.
0 commit comments