Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
express-validate-schema
Advanced tools
Readme
const validateSchema = require('express-validate-schema')
validateSchema([options])
options plain js object
options
for joi.validate on joi repoexpress-validate-schema
will process the http call immediateeach validation should be define before your route function (see examples) either the response
validation
route.get('/', validateSchema().query(query_schema), your_route_function)
validating query string
validateSchema([options]).query(some joi schema)
validating params
validateSchema([options]).params(some joi schema)
validating body
validateSchema([options]).body(some joi schema)
validating headers
validateSchema([options]).headers(some joi schema)
validating a custom key in the req object
validateSchema([options]).custom('key', some joi schema)
validating response
validateSchema([options]).response(some joi schema)
const express = require('express')
const validateSchema = require('express-validate-schema')
const app = express()
const router = express.Router()
// validating the querystring
router.get(
'/querystring',
validateSchema().query(someSchema),
(req, res) => { res.send(someBody) }
)
// validating the params
router.get(
'/params/:id',
validateSchema().params(someSchema),
(req, res) => { res.send(someBody) }
)
// validating the body
router.post(
'/body',
validateSchema().body(someSchema),
(req, res) => { res.send(someBody) }
)
// validating the headers
router.get(
'/headers',
validateSchema().headers(headersSchema),
(req, res) => { res.send(someBody) }
)
// validating the foobar custom req key
router.get(
'/custom/:foobar?',
(req, res, next) => {
req.foobar = req.params.foobar
next()
},
validateSchema({ processHttpCallOnError: true }).custom('foobar', customSchema),
(req, res) => { res.send('custom') }
)
// validating params, body and header
router.put(
'/someresouce/:id',
validateSchema().params(someSchema),
validateSchema()
.body(Joi.object().keys({name: Joi.string().required()})),
validateSchema({ validationOptions: { allowUnknown: true } })
.headers(Joi.object().keys({hello: Joi.string().required()})),
(req, res) => { res.send('yay!') }
)
FAQs
a simple express middleware to validate the request/response objects (body, params, querystring and headers) againts an object schema with joi
The npm package express-validate-schema receives a total of 49 weekly downloads. As such, express-validate-schema popularity was classified as not popular.
We found that express-validate-schema 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.