
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.
interfascist
Advanced tools
Validate JavaScript objects against interfaces
npm install interfascist
You declare interfaces and then you can test if given objects match them.
var geometryInterfaces = {
Point: {
x: 'Number',
y: 'Number'
},
Size: {
width: 'Number',
height: 'Number'
},
Rectangle: {
location: 'Point',
size: 'Size'
},
Color: [ 'red', 'green', 'blue' ],
Colored: {
fill: 'Color',
stroke: 'Color'
},
ColoredRectangle: {
extends: [ 'Rectangle', 'Colored' ]
},
RedRectangle: {
extends: [ 'ColoredRectangle' ],
values: {
fill: 'red'
}
}
};
var validator = new Interfascist( geometryInterfaces );
var rect1 = {
location: { x: 1.3, y: 13 },
size: { width: 25, height: 96.3 },
fill: 'red',
stroke: 'blue'
}
var rect2 = {
location: { x: 41, y: 26 },
size: { width: 55.3, height: 18 }
}
var rect3 = {
location: { x: 1.3, y: 13 },
size: { width: 25, height: 96.3 },
fill: 'purple',
stroke: 'purple'
}
console.log( validator.validate( rect1, 'Point' ) ); //false
console.log( validator.validate( rect1, 'Rectangle' ) ); //true
console.log( validator.validate( rect1, 'ColoredRectangle' ) ); //true
console.log( validator.validate( rect1, 'RedRectangle' ) ); //true
console.log( validator.validate( rect2, 'Rectangle' ) ); //true
console.log( validator.validate( rect2, 'ColoredRectangle' ) ); //false
console.log( validator.validate( rect3, 'Rectangle' ) ); //true
console.log( validator.validate( rect3, 'ColoredRectangle' ) ); //false
There's some more functionality, check out test/test.js until I have a chance to write a better readme.
Run with mocha from the root of interfascist
npm install -g mocha
mocha
It's overwrought for simple validation - if your needs are complex it may suit you better. It didn't suit me.
MIT
FAQs
validate JavaScript objects against interfaces
We found that interfascist 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.