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

166
Views
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
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!