Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda