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

226
Vistas
Joi validate 2 schemas conditionally - Invalid schema content

I'm trying to add conidial schema according of the value of the isCat field in the request body, here is what I have so far: ror [ERR_ASSERTION]: Invalid schema content` error.
What am I missing? Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this

Joi.object({
  params: Joi.object({
    id: Joi.number().required().integer().min(1),
  }),
  body: Joi.object({
    code: Joi.string().required(),
  }).when(Joi.ref("$isValid"), {
    is: Joi.equal(true),
    then: Joi.object({
      body: Joi.object({
        ...entity,
      }),
    }),
    otherwise: Joi.object({
      body: Joi.object({
        ...put,
      }),
    }),
  }),
});

Verify the reference given by you is right Joi.ref("$isValid").
If you provide right reference, this schema will work as you expect.

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