Monday, 3 April 2017

how to access hook object using .validate from feathers-hooks-common

I'm trying to create a simple validator in my feathersjs app and I need to have access to hook.app so I can retrieve the users service and check for uniqueness. Below is my code

checkUniqueEmail = (values, hook) => {
 const userService = hook.app.service('users');
 //below is my validation
}

The problem is that the hook variable is returning undefined instead of the hook object. The feathers-hooks-common github code it shows that this should be possible since hook is being pass as the 2nd parameter. (see below)

const results = validator(getItems(hook), hook); // line 18

I'm not sure what I'm doing wrong here.



via ginad

No comments:

Post a Comment