
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Simple data validation for JavaScript
const rules = {
firstName: r.withMessage(r.string, 'should be a string'),
middleName: r.opt(r.string),
lastName: r.string,
age: r.xor(
r.undefined,
r.and(
r.withMessage(r.integer, 'should be an integer'),
r.withMessage(r.range(10, 99), 'should be between 10 and 99'),
),
),
pokedex: r.validate({
serialNumber: r.pattern(/\d\d\d\d-\d\d\d\d/),
pokemonIds: r.array(
withMessage(
r.and(
r.integer,
r.range(1, 151)
), 'should be an integer between 1 and 151')
),
}),
}
const props = {
firstName: 42,
// middleName is optional
lastName: [],
age: '100',
pokedex: {
serialNumber: '1234-5678',
pokemonIds: [23, 1, 56, '11'],
},
}
r
.validate(rules, props)
.then(() => {
// validation successful
})
.catch(err => {
// err {
// firstName: ['should be a string'],
// lastName: [],
// age: ['should be an integer', 'should be between 10 and 99'],
// pokedex: {
// 'pokemonIds[i]': ['should be an integer between 1 and 151'],
// }
// }
})
FAQs
Simple data validation for JavaScript
We found that rattata 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.