
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
A small, simple and expressive schema builder and data validator.
import _ from 'gateschema'
// Schema creation
const schema = _
.required
.map({
name: _
.required
.string
.notEmpty,
password: _
.required
.string
.notEmpty,
isRemember: _
.optional
.boolean
})
const userInput = {
// ....
}
// Data Validation
// callback style
schema.validate(userInput, (err) => {
if (err) {
// ...
}
// ...
})
// or promise style
schema
.validate(userInput)
.then(() => {
// ...
})
.catch((err) => {
// ...
})
// Serialization
console.log(schema.toJSON()) // or JSON.stringify(schema)
npm install gateschema --save
see API
equal(path: string)format(type: "date" | "date-time" | "hostname" | "uri" | "url" | "email" | "ipv4" | "ipv6")length(range: number | [number] | [undefined, number] | [number, undefined] | [number, number])max(value: number, isExclusive?: boolean)min(value: number, isExclusive?: boolean)not(schema: GateSchema)notEmptypattern(regex: string | RegExp, flags?: string)uniqueconst schema = _
.map({
employed: _
.optional
.boolean
})
.switch('/employed', [
{
// if `employed` is true
case: _
.value(true),
// then the input shoud be a map containing `employee` key
schema: _
.map({
employee: _
.required
.string
})
}
])
const schema = _
.required
.map({
email: _
.switch('/phone', [
{
case: _.required, // if `phone` satisfy `_.required`
schema: _.optional // then `email` is optional
},
{
case: _.any, // else
schema: _.required.$msg('Please input email or phone') // `email` is required
}
])
.string
.format('email'),
phone: _
.switch('/email', [
{
case: _.required,
schema: _.optional
},
{
case: _.any,
schema: _.required.$msg('Please input email or phone')
}
])
.string
})
Another way
const schema = _
.required
.map({
email: _
.optional
.string
.format('email'),
phone: _
.optional
.string
})
.oneOf([
_.map({
email: _.required
}),
_.map({
phone: _.required
})
])
.$msg('Please input email or phone')
See CHANGELOG
MIT
FAQs
GateSchema javascript implementation
We found that gateschema 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.