2.1.8 • Published 8 months ago
@nexys/validation v2.1.8
Validation
Simple, flexible and typesafe validation helpers
Get started
yarn add @nexys/validation
import Validation, {Type, Utils} from '@nexys/validation';
Examples
see tests
Koa example
import Router from 'koa-router';
import bodyParser from 'koa-body';
import Validation, { Utils as VU } from '@nexys/validation';
const router = new Router();
router.post(
'/update',
bodyParser(),
Validation.isShapeMiddleware({
uuid: { extraCheck: VU.checkUuid },
name: {}
}),
async ctx => {
// now that the body has been validated this can be safely typed/cast to the expected type.
// Note that the type should match the validation shape
const { uuid, name }: { uuid: Uuid; name: string } = ctx.request.body;
ctx.body = await myFunc(uuid, name);
}
);
export default router.routes();
2.1.8
8 months ago
2.1.6
10 months ago
2.1.7
10 months ago
2.1.5
3 years ago
2.1.4
3 years ago
2.1.3
3 years ago
2.1.2
4 years ago
2.1.1
4 years ago
2.0.4
4 years ago
2.1.0
4 years ago
2.0.3
4 years ago
2.0.2
4 years ago
1.2.0
4 years ago
1.0.16
4 years ago
1.2.1
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago