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

362
Views
Can one pair Joi's allow() with required()?

Say one has a Joi schema like so:

public static Schema(): Joi.Schema {
  return Joi.object({
    description: Joi.string().max(MAX_STRING_LENGTH).required()
  });
}

Can one pair it with allow() like so:

public static Schema(): Joi.Schema {
  return Joi.object({
    description: Joi.string().max(MAX_STRING_LENGTH).allow(null).required()
  });
}

It seems that .required() overrides .allow(null)? e.g., if one runs this second snippet and attempts to provide null as a value it will be rejected saying that a string is required.

In other words, I think the answer to my question is no, you cannot pair required() and allow() together, allow() is overridden by required(). Is this correct?

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!