Open bruno-brant opened 8 years ago
I have a few ideas concerning how to do it:
Directly on the API
let assert = require("assert-plus");
assert.object(foo, "foo", "%s can't be null");
// or
assert.object(foo, "foo", "%s deve ser preenchido"); // in pt-BR
Globally
let assert = require("assert-plus");
assert.messageTemplate = "%s can't be null";
Locale sensitive
let assert = require("assert-plus");
assert.locale = "pt-BR";
assert.messageTemplate = { "pt-BR": "%s é requerido" };
If someone can provide me with some feedback on the methods, maybe I can slap together a PR during this week.
Assertion messages are composed automatically from the name of the field. They aren't localized, for instance. Allowing users to configure the message would be nice to support other languages and/or custom messages.