spumko/joi — pull request #134 by Marsup (2013-10-21 16:48:34+00:00)
Title: Restore local settings once validated

Hello,

Since validation removes local settings, Hapi couldn't validate objects using local settings more than one time.
The strategy here is to remember those settings and restore them at the end once the validation is done.

About the styling, I'm not sure whether you would rather put it in a function or hoist variables at the top, so feel free to comment if it needs modifications.

I duplicated a few lines in the tests to make sure there would be no regression, I don't know if it's worth their own tests.