Kuzzle data validation plugin
▄▄▄▄▄ ▄███▄ ▄▄▄▄
▄█████████▄▄█████████▄▄████████▄
██████████████████████████████████
▀██████████████████████████████▀
▄███████████████████████████▄
▄███████████████████████████████▄
▀█████████████████████████████████▀
▀██▀ ▀██████▀ ▀██▀
██ ████ ██
▄████▄
▀████▀
▀▀
Simple data validation plugin for Kuzzle back-end. It's verifying input data before writing it to database or publishing. It is based on Joi schemas.
Installation
kuzzle plugins --install --npmVersion x.y.z kuzzle-plugin-schema-validator
Config
Schemas keys are collection names and values are object with path to Joi validator scheme. options
will be passed to Joi validate()
.
Importing config:
kuzzle plugins --importConfig config.json kuzzle-plugin-schema-validator
Simple schema
const Joi = ; moduleexports = Joiobject;
Schema with context generator
const Joi = ; const Schema = Joiobject; Schema { const repositories = pluginContextaccessorskuzzlerepositories; const token = ; if !token return Promise; return repositoriestoken ;}; { if !headers || !headersauthorization return null; const res = /^Bearer $/; if !res return null; const token = res1; return token || null;} moduleexports = Schema;
F.A.Q
Can I use custom validation?
Yes, check Joi.extend() method. Some ready validators can be find on npm.
Changelog
0.2.0
getContext()
to provide dynamic schema data
0.1.0
- schemas are loading at plugin init now (optimization)
activated
schema config option; true by default- throwing
BadRequestError
if validation failed
0.0.2
Initial version