
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
schema-guard
Advanced tools
Create lightweight runtime type guards from a plain object schema
npm install schema-guard
import schemaGuard from 'schema-guard';
const isUser = schemaGuard({
name: 'string',
age: 'number',
email: 'string?',
tags: 'string[]',
active: 'boolean',
});
isUser({name: 'Alice', age: 30, tags: ['admin'], active: true});
//=> true
isUser({name: 123});
//=> false
Returns a type guard function (value: unknown) => boolean.
Type: object
An object mapping property names to type strings.
Supported types: string, number, boolean, bigint, symbol, function, object, array.
Use ? suffix for optional fields (accepts undefined and null):
{email: 'string?'}
Use [] suffix for typed arrays:
{tags: 'string[]'}
Only declared keys are checked. Extra properties on the input value do not cause failure.
Limitations: Nested object validation is not supported. Use 'object' to check that a property is an object, but its shape will not be validated.
MIT
FAQs
Create lightweight runtime type guards from a plain object schema
The npm package schema-guard receives a total of 5 weekly downloads. As such, schema-guard popularity was classified as not popular.
We found that schema-guard demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.