Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
i get 'Joi.object.keys is not a function' error message from nodemon when i try to use .keys()

When i try to use joi.object.keys i get error.I used joi.object.keys function in my previous project but i did not get any error.

const checkSchema = Joi.object.keys({ // error is here
email: Joi.string().email({ minDomainSegments: 2 }),
password: Joi.string().pattern(new RegExp('^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$')),
confirmPassword: Joi.string().valid(Joi.ref('password')).required(),

});

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

There is a possibility that you might be using old version of JOI in your previous projects. In their latest documentation they have removed the object keyword when initializing. You should try this:

const Joi = require("joi");
const checkSchema = Joi.object().keys({ // I changed here
  email: Joi.string().email({ minDomainSegments: 2 }),
  password: Joi.string().pattern(
    new RegExp(
      "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$"
    )
  ),
  confirmPassword: Joi.string().valid(Joi.ref("password")).required(),
});

Documentation Link: https://joi.dev/api/?v=17.4.2

about 4 years ago · Juan Pablo Isaza Report

0

May be due to version change. Have you tried Joi.object().keys({.......})?. This will work. Also please share your version if the above solution didn't work

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!