Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

323
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda