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?