
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
joi-message
Advanced tools
A small package of Joi help you to generate more friendly messages
npm install joi joi-message
yarn add joi joi-message
const { JoiMessage } = require("joi-message");
// example/document.js
Joi.string()
.min(4)
.max(20)
.messages(JoiMessage.createStringMessages({ field: "Username", min: 4, max: 20 }));
// example/usage.js
const Joi = require("joi");
const { JoiMessage } = require("joi-message");
const testSchema = Joi.object({
username: Joi.string()
.min(4)
.max(20)
.messages(JoiMessage.createStringMessages({ field: "Username", min: 4, max: 20 })),
email: Joi.string()
.email()
.messages(JoiMessage.createStringMessages({ field: "Email" })),
list: Joi.array()
.min(4)
.messages(JoiMessage.createArrayMessages({ field: "List", min: 4 })),
listWithoutName: Joi.array()
.min(4)
.messages(JoiMessage.createArrayMessages({ showFieldName: false, min: 4 })),
});
const result = testSchema.validate({ username: "aaa", email: "bbb", list: [1, 2, 3] }, { abortEarly: false });
console.log(result.error.details);
// The return messages will be like this
// [
// {
// message: 'Username should be at least 4 characters',
// type: 'string.min',
// ...
// },
// {
// message: 'invalid email',
// type: 'string.email',
// ...
// },
// {
// message: 'List should contain at least 4 items',
// type: 'array.min',
// ...
// }
// ]
// example/custom.js
const Joi = require("joi");
const { JoiMessage } = require("joi-message");
const testSchema = Joi.object({
username: Joi.string()
.min(4)
.messages({
...JoiMessage.createStringMessages({ field: "Username", min: 4 }),
"string.min": "test message",
}),
});
const result = testSchema.validate({ username: "aaa" });
console.log(result.error.details);
// [
// {
// message: 'test message',
// type: 'string.min',
// ...
// }
// ]
FAQs
a small package of Joi help you to generate more friendly messages
The npm package joi-message receives a total of 0 weekly downloads. As such, joi-message popularity was classified as not popular.
We found that joi-message 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’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.