• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

175
Views
Express Custom Validator siempre devuelve un error

Esto es parte de mi API de inicio de sesión utilizada para validar los detalles del nuevo usuario. La función ifIDAlreadyExist verifica la base de datos y devuelve verdadero/falso para existe/no existe respectivamente.

Incluso cuando el resultado es falso, el mensaje de error se devuelve con el siguiente código. ¿Qué tiene de malo esto?

 const RegInputValdiationRules = () => { return [ check("id") .not() .isEmpty() .withMessage("Please enter the login id") .custom((value) => { ifIDAlreadyExist(value).then((exists) => { console.log(exists); if (exists === true) return Promise.reject(""); else return true; }); }) .withMessage("ID already exists"), check("password") .not() .isEmpty() .isLength({ min: 6 }) .withMessage("Password should contain at least six characters"), ]; };

ingrese la descripción de la imagen aquí

almost 3 years ago · Santiago Trujillo
1 answers
Answer question

0

te falta el return dentro del método custom :

 const RegInputValdiationRules = () => { return [ check("id") .not() .isEmpty() .withMessage("Please enter the login id") .custom((value) => { return ifIDAlreadyExist(value).then((exists) => { console.log(exists); if (exists === true) return Promise.reject(""); else return true; }); }) .withMessage("ID already exists"), check("password") .not() .isEmpty() .isLength({ min: 6 }) .withMessage("Password should contain at least six characters"), ]; };
almost 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error