spumko/joi — pull request #118 by kitcambridge (2013-08-21 02:10:21+00:00)
Title: Complete localization efforts

This pull request extracts all remaining error messages into the default language file, making it possible to override every message with a localized version. This technique may also be used by hapi routes to provide more user-friendly errors—for instance, when validating an incoming form submission, or responding with a message based on the `Accept-Language` header or a cookie.

The changes are backward-compatible; however, some modifications to `Message#print` and `Joi.validate` were necessary:

* The signature of `Message#print` is now `(type, key, replacements, path)`, where `replacements` is an object containing key-value pairs for interpolation. This was changed for compatibility with `ArrayType#includes` and `ArrayType#excludes`, which expose an additional `validTypes` field.
* `Joi.validate` now supports specifying local settings on the `config` object. This makes it possible to set the `languagePath` property (previously, attempting to do so would throw an exception), and allows customizing other global settings for each invocation. Local settings are distinguished from schema fields based on their type: if the `config` object contains a property whose name matches that of a Joi setting, *and* the property value is not a Joi data type, it is assumed to be a local setting.