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

161
Vistas
Joi validation to allow empty spaces

I would like my Joi middleware to keep the alphanum() validation but also allow empty spaces in both event_name and venue_name. I've checked several questions on Stack and the Joi docs without being able to get the correct answer. Here's what I have:

const Joi = require('joi');

module.exports.eventSchema = Joi.object({
    event: Joi.object({
        event_name: Joi.string().alphanum().max(50).required(),
        venue_name: Joi.string().alphanum().max(50).required(),
    }).pattern(/^\s*\w+(?:[^\w,]+\w+)*[^,\w]*$/, Joi.string())
});

Right now, the input below works just fine:

test

However, this input error's out:

test test

How do I allow for spaces in my form validation?

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