
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Fast to write easy to read validation schemas, e.g.
{
a: 'string',
b: [],
c: {
d: 'integer',
e: 'date'
}
}
Joiify will convert the object above to a Joi schema. Why?
{a: 'string', b: []}Note: Joiify will treat Joi objects as pass through so you can safely mix and match Joiify schemes with Joi schemas and do not have to worry about loss of functionality. E.G. Joiify(Joi.string()) compiles to Joi.string()
Note2: Portability is a big deal. You can trivially send a Joiify schema over http as JSON. However this will only work if you do not have any Joi objects in your scheme (re: note above).
Note3: Joiify does not cache the schema result, for optimal performance you should Joiify your scheme before validation time as you would with any Joi schema.
var Joiify = require('joiify')
var AccountSchema = Joiify({
AccountID: 'string',
lastLogin: 'date',
//Any values that are already Joi objects will included verbatim
role: Joi.any().valid(['user', 'manager', 'admin']),
profile: {
url: 'string',
email: 'email',
age: 'integer',
//special rules for this object
'*': {required: true, unknown: false, min: 1, max: 10}
})
AccountSchema.validate(data, function(err, data){
//just a nornmal joi schema
})
//AccountSchema equivalent to:
Joi.object().keys({
AccountID: Joi.string(),
lastLogin: Joi.date(),
role: Joi.any().valide(['user', 'manager', 'admin']),
profile: Joi.object().requiredKeys(['url', 'email', 'age']).unknown(false).min(1).max(10).keys({
url: Joi.string(),
email: Joi.string().email(),
age: Joi.number().integer(),
})
})
Joiify accepts one argument the "scheme" which should be one of the following:
Convert the a joiify "scheme" into a Joi "schema" where the scheme argument is one of the following
string: A value which is converted to a corresponding Joi typeObject: An object. Object children will be recursively Joiified.Array: An array. Array children will be used to validate array elements.
See details below for conversion rules"string": Joi.string()"email": Joi.string().email()"hostname": Joi.string().hostname()"alphanum": Joi.string().alphanum()"hex": Joi.string().hex()"token": Joi.string().token()"number": Joi.number()"integer": Joi.number().integer()"date": Joi.date()"boolean": Joi.boolean()"binary": Joi.binary()"func": Joi.func()"array": Joi.array()"object": Joi.object()"forbidden": Joi.any().forbidden()undefined: Joi.any().forbidden()null: Joi.any().valid(null)[]: Joi.array()
Joi.array().includes(){}: Joi.object()
'*' if set specifies special handlers for the object validation as follows
required: boolean, marks as required (true) or optional (false) all keys on the objectunknown: boolean, allows (true) or disallows (false) unknown keys on the objectmax: integer, sets the maximum number of keys on the objectmin: integer, sets the minimum number of keys on the objectFAQs
Easy to read and fast to write Joi schemas
We found that joiify 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.