Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@typeonly/validator
Advanced tools
An API to validate JSON data or JavaScript objects, using TypeScript typing definitions.
TypeOnly aims to be the pure typing part of TypeScript. This package provides an API to validate JSON and JavaScript objects with TypeScript definitions, using the TypeOnly parser.
At first, it is necessary to follow the tutorial of TypeOnly in order to generate a .to.json
file based on your TypeScript definitions. After this step, you have the following file: dist/types.to.json
.
Now, add @typeonly/validator
to the project:
npm install @typeonly/validator
Create a file src/validate-main.js
with the following content:
// src/validate-main.js
const { createValidator } = require("@typeonly/validator");
const data = {
color: "green",
shape: {
kind: "circle",
x: 100,
y: 100,
radius: 50
}
};
const validator = createValidator({
bundle: require("./types.to.json")
});
const result = validator.validate("./drawing", "Drawing", data);
console.log(result);
This code validates the data
object using RTO files generated by the TypeOnly parser.
Execute it:
$ node src/validate-main.js
{ valid: true }
With VS Code, our recommanded plugin is:
ms-vscode.vscode-typescript-tslint-plugin
)FAQs
An API to validate JSON data or JavaScript objects, using TypeScript typing definitions.
The npm package @typeonly/validator receives a total of 195 weekly downloads. As such, @typeonly/validator popularity was classified as not popular.
We found that @typeonly/validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.