
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
Vex is a handy client side and Node module that "proofs" an object according to a supplied schema.
If the object doesn't satisfy the schema, then schema is considered "vexed", thus the object will be rejected.
npm install vex
Then simply require
var vex = require('vex');
vex.js and vex.min.js are available in the dist folder.
Client-side Vex is a UMD bundle generated with Browserify,
this means if you're using Require.js or some form of AMD
you can load it as a client-side module using your
module loader of choice. If not vex is exported to the
global scope as vex.
The client code can be generated with
npm run dist
var schema = {
name: String
}
function doSomething(config) {
vex(config, schema);
//do stuff
}
function doSomething(config) {
vex(config);
//do things
}
doSomething.schema = {
name: String
}
function doSomething(config) {
vex(config);
//do stuff
}
doSomething.schema = {
opt: {
name: String,
},
req: {
id: Number
}
}
function doSomething(name, id) {
vex(arguments);
//do stuff
}
doSomething.schema = [String, {req:{id: Number}}];
By default Vex will throw if a schema hasn't been fulfilled.
We can turn this behaviour off:
var vex = require('vex');
var schema = {
name: String
}
function buildAThing(config) {
if (vex(config, schema)) {
//handle error state:
console.error('oh oh', vex.status())
return;
}
//do stuff
}
If a config doesn't satisfy a schema, vex will return true (to let us know it has been vexed). This allows us to validate the schema at the top of the function and return early if there's a problem (that is if vex throwing is turned off).
If vex returned false when the schema wasn't satisfied we'd either have to preceed the check with a not (!) or otherwise handle problems at the bottom of the function with an else statement - which would create an extra level of nexting and put error handling in an unintuitive place (at the bottom).
Tests are written with mocha framework, to run simply do
npm test
To run browsers tests install testling
npm -g i testling
The run testling with the desired browser
For instance, chrome on linux:
testling -x google-chrome
Or chrome on OS X
testling -x open -a 'Google Chrome'
FAQs
A Schema Validator
The npm package vex receives a total of 573 weekly downloads. As such, vex popularity was classified as not popular.
We found that vex 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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.