1.0.4 • Published 4 years ago
@tradeshack/api-validator v1.0.4
Tradeshack API Validator
Api Validator is a lightweight wrapper around express-validator. It provides out of the box error messages for common validation errors. It allows for automatic rule execution on express routes.
Installation
npm install --save @tradeshack/api-validator
Usage
const { validate, rule } = require('@tradeshack/api-validator');
app.post(
'/accept/:token',
validate([
rule('firstName').nonEmpty(),
rule('lastName').nonEmpty(),
rule('email').nonEmpty(),
rule('password').nonEmpty().isMinLength(5),
]),
(request, response) => {});