Feathers hooks for schema validation extended from fastest-validator
Recommended using either yarn or npm for install.
# NPM
$ npm install feathers-fastest-validator --save
# YARN
$ yarn add feathers-fastest-validator
The library is extended from Fastest Validator to support validate function on Feathers hook. For others Fastest Validator function such as add custom rules, add customized error message, add alias validation, and etc. Please read more on https://github.com/icebob/fastest-validator. Here's an example of a Feathers server that uses feathers-fastest-validator.
const Validator = require('feathers-fastest-validator');
// create validator instance
const validator = new Validator();
// More information about schema validation,
// please visit here https://github.com/icebob/fastest-validator
const schema = {
key: { type: 'string' },
}
// The data that need to validate
const field = 'data'
// The hooks can only use as a `before` hooks
export.before = {
create: [ validator.validateHook(schema, field) ]
}The parameter for validateHook(schema, field).
| Parameter | Default | Type | Description |
|---|---|---|---|
| schema | - | ValidationSchema |
Please visit https://github.com/icebob/fastest-validator |
| field | data |
string |
the reference of data which need to validate such as context.data or context.params.query. For more info about feathers hook context plese visit https://docs.feathersjs.com/api/hooks.html. |
Copyright (c) 2018
Licensed under the MIT license.

