feathers-plus / validate-joi-mongodb

MongoDB utilities for @feathers-plus/validate-joi
MIT License
3 stars 0 forks source link

Error: Cannot mix different versions of Joi schemas #4

Open bradbeatson opened 2 years ago

bradbeatson commented 2 years ago

using: "@feathers-plus/validate-joi": "^3.4.0", "@feathers-plus/validate-joi-mongodb": "^1.0.0", "@feathersjs/authentication": "^4.5.12", "@feathersjs/authentication-local": "^4.5.12", "@feathersjs/authentication-oauth": "^4.5.12", "@feathersjs/configuration": "^4.5.12", "@feathersjs/errors": "^4.5.12", "@feathersjs/express": "^4.5.12", "@feathersjs/feathers": "^4.5.12", "@feathersjs/socketio": "^4.5.13", "@feathersjs/transport-commons": "^4.5.12", "compression": "^1.7.4", "cors": "^2.8.5", "express-subdomain": "^1.0.5", "feathers-mongodb": "^6.4.1", "helmet": "^4.6.0", "joi": "^17.4.0", "moment": "^2.29.1", "mongodb": "^4.3.1", "mongodb-core": "^3.2.7", "pug": "^3.0.2", "serve-favicon": "^2.5.0", "validator": "^13.7.0", "winston": "^3.5.0"

The following results in an error: "Error: Cannot mix different versions of joi schemas" validate.validateProvidedData(attrs, { abortEarly: false })

model being used:

const Joi = require('joi');
const { objectId } = ('@feathers-plus/validate-joi-mongodb');

const attrs = {
  _id: objectId(),
  email: Joi.string().disallow(null).required(),
  password: Joi.string().disallow(null).required(),
  firstName: Joi.string().disallow(null).required(),
  lastName: Joi.string().disallow(null).required(),
  profilePicture: Joi.string().disallow(null),
  createdAt: Joi.date().required(),
  updatedAt: Joi.date().required()
};

module.exports = {
  attrs,
  schema: Joi.object(attrs)
};

being used within before patch hook

bradbeatson commented 2 years ago

updating dependencies to use feathers-validate-joi as opposed to @feathers-plus/validate-joi fixed the issue. However, there's still a require inside object-ids-in-query.js that needs amending, should be: const validate = require("feathers-validate-joi");