express-validator array params

node v8.17.0
version: 2.0.0
endpointsharetweet
var express = require("@runkit/runkit/express-endpoint/1.0.0"); const { checkSchema, validationResult } = require("express-validator/check"); var app = express(exports); app.get( "/a", checkSchema({ foo: { in: "query", isAlphanumeric: true, optional: true, }, }), handler ); app.get( "/b", checkSchema({ 'foo.*': { in: "query", isAlphanumeric: true, optional: true, }, }), handler ); function handler(req, res) { const errors = validationResult(req); if (!errors.isEmpty()) { res.status(400).send({ errors: errors.array() }); } else { res.send({ foo: req.query.foo, }); } }
Loading…

no comments

    sign in to comment