Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
I am getting "Joi.validate is not a function" when I try and send a request through postman

Hello I am pretty new to node.js and postman. I am having a problem when I try to send a body raw message from postman I get a TypeError in my terminal saying Joi.validate is not a function. I'm not sure what my problem is any help would be appreciated thanks in advance.

 //Validation
    const Joi = require('joi');
    
    //Register Validation
    const registerValidation = data  => {
    const schema = {
        name: Joi.string()
            .min(6)
            .required(),
        email: Joi.string()
            .min(6)
            .required()
            .email(),
        password: Joi.string()
            .min(6)
            .required()
        };
        return Joi.validate(data, schema);
    };
    
    //Login Validation
    const loginValidation = data  => {
        const schema = {
            email: Joi.string()
                .min(6)
                .required()
                .email(),
            password: Joi.string()
                .min(6)
                .required()
                
            };
            return Joi.validate(data, schema);
        };
    
    module.exports.registerValidation = registerValidation;
    module.exports.loginValidation = loginValidation;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Validation is part of the schema you've created with Joi and not a method on the library itself.

Check the docs for it:

//Validation
const Joi = require('joi');
    
    //Register Validation
    const registerValidation = data  => {
        const schema = Joi.object({
            name: Joi.string()
                .min(6)
                .required(),
            email: Joi.string()
                .min(6)
                .required()
                .email(),
            password: Joi.string()
                .min(6)
                .required()
        });
        return schema.validate(data);
    };
    
    //Login Validation
    const loginValidation = data  => {
        const schema = Joi.object({
            email: Joi.string()
                .min(6)
                .required()
                .email(),
            password: Joi.string()
                .min(6)
                .required()
            };
            return schema.validate(data;
        });
    
    module.exports.registerValidation = registerValidation;
    module.exports.loginValidation = loginValidation;

One thing to keep in mind is that you could define your schemas outside the arrow functions to increase performance.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda