⚓️ A Feathers Hook to validate data based on model.
import validate from 'feathers-validations';
validate(model, 'Custom general error message.');
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.'
// }
// }