Skip to content

Commit

Permalink
deps and passthrough validation error. Closes #3136. Closes #3137. Cl…
Browse files Browse the repository at this point in the history
…oses #3138. Closes #3139. Closes #3140. Closes #3141. Closes #3142. Closes #3143. Closes #3144. Closes #3145. Closes #3146. Closes #3147
  • Loading branch information
hueniverse committed May 7, 2016
1 parent 40dbdc1 commit faacf02
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 13.2.x API Reference
# 13.4.x API Reference

- [Server](#server)
- [`new Server([options])`](#new-serveroptions)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Lead Maintainer: [Eran Hammer](https://github.com/hueniverse)
authentication, and other essential facilities for building web and services applications. **hapi** enables
developers to focus on writing reusable application logic in a highly modular and prescriptive approach.

Development version: **13.2.x** ([release notes](https://github.com/hapijs/hapi/issues?labels=release+notes&page=1&state=closed))
Development version: **13.4.x** ([release notes](https://github.com/hapijs/hapi/issues?labels=release+notes&page=1&state=closed))
[![Build Status](https://secure.travis-ci.org/hapijs/hapi.svg)](http://travis-ci.org/hapijs/hapi)

For the latest updates, [change log](http://hapijs.com/updates), and release information visit [hapijs.com](http://hapijs.com) and follow [@hapijs](https://twitter.com/hapijs) on twitter. If you have questions, please open an issue in the
Expand Down
2 changes: 1 addition & 1 deletion lib/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internals.input = function (source, request, next) {

// Prepare error

const error = Boom.badRequest(err.message, err);
const error = (err.isBoom ? err : Boom.badRequest(err.message, err));
error.output.payload.validation = { source: source, keys: [] };
if (err.details) {
for (let i = 0; i < err.details.length; ++i) {
Expand Down
24 changes: 12 additions & 12 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hapi",
"description": "HTTP Server framework",
"homepage": "http://hapijs.com",
"version": "13.3.0",
"version": "13.4.0",
"repository": {
"type": "git",
"url": "git://github.com/hapijs/hapi"
Expand All @@ -26,7 +26,7 @@
"catbox-memory": "2.x.x",
"cryptiles": "3.x.x",
"heavy": "4.x.x",
"hoek": "3.x.x",
"hoek": "4.x.x",
"iron": "4.x.x",
"items": "2.x.x",
"joi": "8.x.x",
Expand Down
27 changes: 27 additions & 0 deletions test/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,33 @@ describe('validation', () => {
});
});

it('retains custom validation error', (done) => {

const server = new Hapi.Server();
server.connection();
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {

return reply('ok');
},
config: {
validate: {
query: {
a: Joi.number().error(Boom.forbidden())
}
}
}
});

server.inject('/?a=abc', (res) => {

expect(res.statusCode).to.equal(403);
done();
});
});

it('validates valid input with validation options', (done) => {

const server = new Hapi.Server();
Expand Down

0 comments on commit faacf02

Please sign in to comment.