feathers-fastest-validator

2.0.0 • Public • Published

feathers-fastest-validator

Build Status Coverage Status Download Status npm version

Feathers hooks for schema validation extended from fastest-validator

Table of content

Installation

Recommended using either yarn or npm for install.

# NPM
$ npm install feathers-fastest-validator --save

# YARN
$ yarn add feathers-fastest-validator

Usage

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) ]
}

Properties

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.

License

Copyright (c) 2018

Licensed under the MIT license.

"Buy Me A Coffee"

Package Sidebar

Install

npm i feathers-fastest-validator

Weekly Downloads

8

Version

2.0.0

License

MIT

Unpacked Size

13 kB

Total Files

12

Last publish

Collaborators

  • pr1te