[Solved] Meteor mdg:validated-method without using simple schema

I’m using Joi (browser version) and a custom mixin:

export const joiValidation = function (methodOptions) {
  if (methodOptions.schema) {
    methodOptions.validate = (data) => {
      const result = methodOptions.schema.validate(data, { stripUnknown: true });
    
      if (result.error) {
        throw new ValidationError(result.error.details.map(error => {
          // map joi error to ValidationError
          return {
            name: error.path,
            type: error.type,
            message: error.message
          };
        }));
      }

      // call validatedMethod.run with the validated/cleaned values!
      const runFunc = methodOptions.run;
      methodOptions.run = function () {
        return runFunc.bind(this)(result.value);
      }
    }
  }

  return methodOptions;
};

One advantage of this setup is that i can reuse the Joi schema for form validation with redux-form.