Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error: Cannot mix different versions of Joi schemas #4

Open
bradbeatson opened this issue Jan 31, 2022 · 1 comment
Open

Error: Cannot mix different versions of Joi schemas #4

bradbeatson opened this issue Jan 31, 2022 · 1 comment

Comments

@bradbeatson
Copy link

bradbeatson commented Jan 31, 2022

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
Copy link
Author

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");

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant