How to create custom service and register a JOI validator?
When you create a mongoose service with createModelFromJoi()
we set your JOI schema inside the app and then we find this instance from validateSchema hook,
if you create a new custom service and don't use createModelFromJoi()
then use setJoiInstance(app, serviceName, joiSchema)
const commentsValidators = require('../validators/comments.validators.js');
const {setJoiInstance} = require('feathers-mongoose-casl');
module.exports = function (app) {
// your custom 'comments' service
setJoiInstance(app, 'comments', commentsValidators);
services.configureServices(app);
};
setJoiInstance most to come before
services.configureServices(app);