Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
koa-fluent-validation
Advanced tools
Fluent, functional, and extendable validation for Koa 2 body, params, and query. Built on validator for base validations and filters.
yarn add koa-fluent-validation
# OR
npm i koa-fluent-validation
ctx.params
.const Koa = require('koa');
const bodyparser = require('koa-bodyparser');
const { validator, v, f } = require('koa-fluent-validation');
const app = new Koa();
app.use(bodyparser());
app.use(validator());
app.use(async (ctx, next) => {
try {
await next();
} catch (e) {
if (e.status === 422) {
ctx.body = ctx.validationErrors;
return;
}
// ... some other handling here etc
}
});
// simple post route
app.use(async (ctx, next) => {
if (ctx.method !== 'POST') {
ctx.throw(404);
return;
}
ctx.validateBody(
{
firstName: v()
.required()
.string(),
lastName: v()
.required()
.string()
},
{
firstName: f().trim(),
lastName: f().trim()
}
);
// your code here
});
app.listen(8080);
For documentation see the wiki!
FAQs
[![npm](https://img.shields.io/npm/v/koa-fluent-validation.svg?style=for-the-badge)](https://npmjs.com/package/koa-fluent-validation) [![Travis (.org)](https://img.shields.io/travis/technicallyjosh/koa-fluent-validation.svg?style=for-the-badge)](https://t
The npm package koa-fluent-validation receives a total of 9 weekly downloads. As such, koa-fluent-validation popularity was classified as not popular.
We found that koa-fluent-validation 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.