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

317
Views
Joi not accepting correct string value with valid ()

I have a form with a dropdown input, so the options for that input are already set.

The problem is that the value of the input, despite being correct and it is within the accepted values of the schema I got the message that Provider must be one of [[object Set], [object Set]].

Most weird thing is that this problem is ocurring in production, but in localhost I don't get this validation error.

provider key from the schema:

 provider: Joi.string().required().label('Provider').when('entitlementType', {
    is: 'Offer', 
    then: Joi.string().valid(...providersForSubscriptions),
    otherwise: Joi.string().valid(...providersForProducts),
  }),

providersForSubscriptions array:

[
    "RBL",
]

providersForProducts array:

[
    "RBL",
    "content-store",
    "zencore",
    "VIP"
]

As you can see is a quite simple validation, it will receive some provider value and will accept the value if it's within the valid arrays.

Loging the form in the browser.

console.log(entitlementType, provider, providersForProducts);

And this is the output:

enter image description here

So what's going on? If we check the context from the validation warning, the input value is zencore and zencore is considered as a valid value.

Any thoughts? Should I try refactoring the schema? Why this is prod only?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From your schema:

provider: Joi.string().required().label('Provider').when('entitlementType', {
    is: 'Offer', 
    then: Joi.string().valid(...providersForSubscriptions),
    otherwise: Joi.string().valid(...providersForProducts),
  }),

And your output, we can see that entitlementType is NOT offer. So that means

Joi.string().valid(...providersForProducts),

is being used for validation on this particular field.

We can also see the error Provider must be one of [[object Set], [object Set]] which means that Joi is checking against an array of sets.

That points us to providersForProducts as the culprit.

Why is it an array of sets? Who knows. Log that value to confirm and then work your way back to see why it's set as such.

about 4 years ago · Juan Pablo Isaza Report
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!