feathers-validations
v1.0.1
Published
⚓️ A Feathers Hook to validate data based on model.
Downloads
58
Maintainers
Readme
feathers-validations
⚓️ A Feathers Hook to validate data based on model.
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.'
// }
// }