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

245
Views
Email validation is not working in node js

I have written code to perform email validation and password validation, but it is not returning any error if condition is not satisfied, didn't get any idea what is wrong with my code.

code in validation.js file

const { check } = require('express-validator');
 
exports.signupValidation = [
    check('name', 'Name is requied').not().isEmpty(),
    check('email', 'Please include a valid email').isEmail().normalizeEmail({ gmail_remove_dots: true }),
    check('password', 'Password must be 6 or more characters').isLength({ min: 6 })
]
 

Code in router.js

const express = require('express');
const router = express.Router();
const db  = require('./dbConnection');
const { signupValidation, loginValidation } = require('./validation');
const { validationResult } = require('express-validator');

router.post('/register', signupValidation, (req, res, next) => {
// already return in validation.js file to throw error, what is the exact way to return error message
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

router.post('/register', signupValidation, (req, res, next) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
    return res.status(422).json({
        status: "failure",
        error: {
            message: "Invalid data to proceed",
            type: "ValidationException",
            code: 422,
            error_data: errors.array(),
        },
    });
}
next();

});

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!