bace9b4949
* Add joi and next-joi example * Add more README information * Update examples/with-joi/package.json Co-authored-by: Lee Robinson <me@leerob.io> * Update all dependencies to latest Co-authored-by: Lee Robinson <me@leerob.io>
13 lines
324 B
JavaScript
13 lines
324 B
JavaScript
import Joi from 'joi'
|
|
import { validate } from '../../server/api/middlewares/validate'
|
|
|
|
const carSchema = Joi.object({
|
|
brand: Joi.string().required(),
|
|
model: Joi.string().required(),
|
|
})
|
|
|
|
export default validate({ body: carSchema }, (req, res) => {
|
|
const car = req.body
|
|
|
|
return res.status(201).json({ data: car })
|
|
})
|