Created
February 25, 2015 18:42
-
-
Save sarhugo/6ec6929a98697cfd8a1a to your computer and use it in GitHub Desktop.
How to reproduce https://github.com/hapijs/hapi/issues/2431
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Hapi = require('hapi'), | |
Joi = require('joi'); | |
var server = new Hapi.Server(); | |
server.connection(); | |
server.route({ | |
method: 'POST', | |
path: '/', | |
config: { | |
validate: { | |
payload: Joi.object({ | |
password: Joi.string(), | |
confirm: Joi.object().keys({ | |
password: Joi.string() | |
}) | |
}).assert('confirm.password', Joi.ref('password')) | |
}, | |
handler: function (request, reply) { | |
reply('Ok'); | |
} | |
} | |
}); | |
server.start(function () { | |
server.inject({ | |
method: 'POST', | |
url: '/', | |
payload: { | |
password: '123456', | |
confirm: { | |
password: '1234567' | |
} | |
} | |
}, function (response) { | |
/* | |
Should return { source: 'payload', keys: [ 'confirm.password' ] } | |
instead it returns: { source: 'payload', keys: [ 'value' ] } | |
*/ | |
console.log(response.result.validation); | |
}); | |
server.stop(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment