
Product
Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.
i18n error messages extension for Joi Joi
For using joi-x-i18n is very simple:
'use strict';
const Joi = require('joi-x-i18n')(require('joi'), __dirname + '/locales');
You must send to joi-x-i18n an intance of Joi and the directory of the translation files.
After, initializing the module, you have the instance of Joi, and you can use that like you use Joi.
You can translate your messages, simple adding an extra option in your validate function.
let schema = {
name: Joi.string().required()
};
let value = {};
Joi.validate(value, schema, {i18n: 'zh_CN'}, function (err, data) {
console.log(err, data);
});
// output
/*
{ [ValidationError: 成员"name"失败因为:["name" 是必须的]]
isJoi: true,
name: 'ValidationError',
details:
[ { message: '"name" 是必须的',
path: 'name',
type: 'any.required',
context: [Object] } ],
_object: {},
annotate: [Function] } {}
*/
For more information about how translate the tokens, you can see the zh_CN translation inside the locales directory in this project.
NOTE: If you specify an invalid path to your folders we just use the default english version for the errors or the translations default in the i18n directory in this project.
After all, you just have a Joi instance, you can use that like you use Joi in your project, no incompatibilities with an existing implementation.
To contribute you can try to find an issue or enchancment and try to implement it. Fork the project, implement the code, make tests and send the PR to the master branch.
For testing you just need run npm install && npm test inside root folder of this project.
(The MIT License)
Copyright (c) 2018 Logoran contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
i18n error messages extension for Joi
The npm package joi-x-i18n receives a total of 27 weekly downloads. As such, joi-x-i18n popularity was classified as not popular.
We found that joi-x-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.