在将joi-password-complexity集成到我的Joi验证逻辑时遇到了一些麻烦。我得到的错误是Cannot mix different versions of joi schemas
。我需要更改什么?
schemasShared.js
const Joi = require('@hapi/joi');
const JoiPasswordComplexity = require('joi-password-complexity');
const joiPasswordComplexityOptions = {
min: 10,
max: 50,
lowerCase: 1,
upperCase: 1,
numeric: 1,
symbol: 1,
requirementCount: 4,
};
const passwordLogin = new JoiPasswordComplexity(
joiPasswordComplexityOptions
);
module.exports = {
passwordLogin
};
auth.schemas.js
const Joi = require('@hapi/joi');
const schemasShared = require('../../utils/schemasShared');
const authRequirements = {
password: schemasShared.passwordLogin,
}
const authSchemas = {
loginBody: Joi.object({ // The error points to this line, specifically to .object
password: authRequirements
.password
.required(),
}),
}
我的版本: