
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.
Validate you JSON now!
import { group, object, required, string } from "json-sv";
const test = object({
firstName: string(),
lastName: group([
required(),
string(),
]).when(required().ref("firstName")),
});
const errors = test.errors({
firstName: "Ivan",
});
console.log("Errors:", errors);
Uses JSON format for a Schema declaration. For example:
{
"$type": "object",
"keys": {
"a": {
"$type": "required"
},
"b": {
"$type": "required",
"$when": {
"$type": "required",
"$context": ["a"]
}
}
}
}
A base Validators declaration should contains follow propertie: $type - string, one of available validators name. If you want to declare conditionaly validator (should be current validator execut, or not), use $when - schema. When you uses $when, internal conditional validator checks same data (from parent validator), for changing validation context, use $context - array of string, a route in root data.
type ISchemaContext = string[];
interface ISchema {
$type: string;
$when?: ISchema;
$context?: ISchemaContext;
}
You can parse a object declaration or a JSON string to the Validator. Also actually you can create the object declaration or the JSON string from a Validator.
import { Schema, group, object, required, string } from "schema-validator";
const subSchema = Schema.parse(mySchemaJsonStringOrObject);
const schema = object({
name: group([
required(),
string(),
]),
data: subSchema,
});
const finalSchemaObject = Schema.objectify(schema);
const finalSchemaObject_1 = schema.schema;
const finalSchemaJson = Schema.stringify(schema);
const finalSchemaJson_1 = JSON.stringify(schema.schema);
FAQs
JSON Schema Validator
We found that json-sv 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.