
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
entityforge
Advanced tools
An integer isn't a data type, it's a compiler hint.
Define a model to match reality:
import {EF} from "entityforge";
let UserForge = EF.obj({
uuid: EF.string().minLength(20).maxLength(20).ascii(),
email: EF.string().minLength(5).maxLength(255),
memberSince: EF.int(2016).min(2000).max(2200)
})
Now create an instance of your model:
let NullableUserModel = UserForge.asNewable()
let example = new NullableUserModel()
console.log("UUID: ", example.uuid) // null
console.log("Email: ", example.email) // null
console.log("MemberSince: ", example.memberSince) // 2016
example.uuid = "-JhLeOlGIEjaIOFHR0xd"
example.email = "foo@bar.com"
try {
example.uuid = example.uuid.substring(0, 10)
} catch (e) {
console.log("I'm sorry dave....") // Nope, not allowed.
console.log("Validation errors provide a cause", e.cause);
console.log("To be clear, the messaging system needs some work. The cause message is: ", e.cause.minLength.message) // @restriction.minLength
}
console.log("UUID wasn't modified by the attempt to set it to illegal value:", example.uuid) // "-JhLeOlGIEjaIOFHR0xd" --- value not modified if invalid.
Take care to recognize that there is a difference between setting minLength to zero and not allowing null. A null string is still valid even if minLength is set to zero.
One advantage of specifying our data type in detail is that we can use that specification to do cool things. Like generate semi-random instances of our models:
let randomUser = UserForge.gen()
console.log(randomUser) // This instance will be as valid (or invalid) as your Forge definition constraints allow.
There is still work to be done on the data generation side. Of the missing functionality, the most important is the handling of cases that are hard to code for explicitly, such as string matching on a regex.
The initial batch of forges cover the basic primitive types, and object wrappers:
let BiggerUserForge = EF.obj({
uuid: EF.string().minLength(20).maxLength(20).ascii(),
email: EF.string().minLength(5).maxLength(255),
memberSince: EF.int(2016).min(2000).max(2200),
karmaScore: EF.number().min(0).max(1).initTo(0.5),
groups: EF.enumeration().values(["admin", "guest", "subscriber", "paid-member"]),
contact: EF.obj({
surname: EF.string().minLength(1).maxLength(255).ascii(),
forename: EF.string().minLength(1).maxLength(255).ascii(),
addressLine1: EF.string().minLength(1).maxLength(255).ascii(),
addressLine2: EF.string().minLength(1).maxLength(255).ascii(),
postcode: EF.string().minLength(3).maxLength(25).ascii(),
})
})
let biggerUser = BiggerUserForge.gen()
console.log("A randomly generated 'BiggerUser:", biggerUser)
npm install
npm run test
FAQs
Entities >> Objects
We found that entityforge 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.