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

202
Vistas
sequelize.js custom validator for unique email to stop when user try to forgot password
email: {
        type: DataTypes.STRING,
        allowNull: false,
        validate: {
            notNull: {
                args: true,
                msg: "Email is required"
            },
            notEmpty: {
                args: true,
                msg: "Email is required."
            },
            isEmail: {
                args: true,
                msg: "Email is not valid."
            },
            isUnique: function (value, next) {
                var self = this;
                User.findOne({where: {email: value}})
                .then(function (user) {
                    // reject if a different user wants to use the same email
                    if (user && self.id !== user.id) {
                        return next('Email already exists!');
                    }
                    return next();
                }).catch(function (err) {
                    return next(err);
                });
            }
        }
    }

its working good when user create but when try to forgot password it show email already exist i need to avoid isUnique on that time because then user email exists in database which is valid point but isUnique validation fail which not need to run that time .Any help please

about 4 years ago · Juan Pablo Isaza
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