Skip to content

roganmelo/feathers-validations

Repository files navigation

feathers-validations

⚓️ A Feathers Hook to validate data based on model.

NPM version Build StatusCode Coverage 100%ISC LicenseNodeJS

API

import validate from 'feathers-validations';

validate(model, 'Custom general error message.');

Usage

  import validate from 'feathers-validations';
  import { required } from 'data-validations';

  const validations = { name: [required('Name is required.')] };

  export default {
    before: {
      create: [validate(validations)]
    }
  };

  // Error
  // {
  //   type: 'FeathersError',
  //   name: 'BadRequest',
  //   message: 'Validation error.',
  //   code: 400,
  //   className: 'bad-request',
  //   data: {},
  //   errors: {
  //     name: 'Name is required.'
  //   }
  // }

About

⚓️ A Feathers Hook to validate data based on model.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published