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

272
Vistas
How to use the blacklist method from express-validator

I have the following post request that validates some data:

app.post(
  "/review",
  [
    // Add the middleware to validate email and restaurant info below:
    check("email").isEmail(),
    check("restaurant").notEmpty().blacklist("<>"),
    check("rating").isNumeric(),
    check("review").notEmpty().blacklist("<>")
  ],
// ...

The documentation for validator.js demonstrates to use the blacklist method as follows:


blacklist(input, '\\[\\]')

Considering the context of how i'm adding my middleware, it's a bit confusing to understand what exactly should be the input parameter. I'm already using the check method to look for the input field, what exactly should go in the blacklist method?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Since you are using [express-validator][1] which works as a wrapper over [validator.js][1], the input is injected to the blacklist method by the express-validator and in your case, since you are using check() method of express-validator the input will be the parameter with the label that you have provided as the argument to check() method which might exist in any of the following request objects:

  • req.body
  • req.cookies
  • req.headers
  • req.params
  • req.query

In your case for check("restaurant").notEmpty().blacklist("<>"), a parameter with the label of restaurant will be extract from either one of the aforementioned request objects and for check("review").notEmpty().blacklist("<>"), a parameter with the label review will be extracted.

So the only argument that should be provided for the check method is a regex string which specifies the characters that must get removed.

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