
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.
schema-check
Advanced tools
A JavaScript Object Schema Validator for loose type checking on object property setting
#Schema Check
Schema Check is an object validation and checking package designed to allow you to easily restrict what can be put on certain fields on a JavaScript Object.
Uses Object.defineProperty and private fields prefixed with '__'
To Install:
npm install schema-check
###Usage Pass in an object, schema and options (additional settings for the SchemaCheck)
var SchemaCheck = require('schema-check');
var obj = {
name: "test",
rating: 5,
settings: {
is_active: true
}
};
var schema = {
name: {
type: "string",
allow_nulls: false,
editable: false,
},
rating: {
type: "number"
},
settings: {
is_active: {
type: "boolean"
}
}
};
var options = {
//Should additional fields be allowed? Defaults to false
is_strict: false, //TODO - this isn't working yet
//Does adding an invalid field throw a TypeError or fail silently? Defaults to true
throw_error: true
};
var newObj = SchemaCheck(obj, schema, options);
//or
SchemaCheck(obj, schema);
//Examples
//Modifying Name doesn't work since editable is false
obj.name = "bob";
obj.name; //test
//Modifying Rating does work
obj.rating = 10;
obj.rating; //10
//Trying to set rating to a string throws an error
obj.rating = "10"; //Throws TypeError;
//Set a nested value
obj.settings.is_active = false;
//Throws error
obj.settings.is_active = "true"; //Throws TypeError;
Schemas can have the following format:
{
field: {
type: 'string', //string, number, boolean
regex: /^test$/, //regex - for string types only
min: 5, //number minimum - value must be greater than or equal to this number - number types only
max: 5, //number maximum - value must be less than or equal to this number - number types only
allow_nulls: false, //true, false - default false - can you have nulls in this field?
allow_delete: false, //true, false - default false - can you delete this field?
editable: false //true, false - default true - is there a Setter?
}
}
Working So Far:
To Do:
View the Github repo here: https://github.com/WakeskaterX/schema-check
Also added debug, so if you want to view logging levels the debug strings are:
I'll try to add more logs as well using debug
FAQs
A JavaScript Object Schema Validator for loose type checking on object property setting
We found that schema-check 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.