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

175
Vistas
How can I have multiple unique checks with a Joi schema validation?

I have data:

const mockScenario1 = {
  drawingNode: {
    moduleRackOutputs: [
      {
        moduleId: 'module1',
        tilt: 'tilt1',
        rack: {
          framingType: 'framing1'
        }
      },
      {
        moduleId: 'module2',
        tilt: 'tilt1',
        rack: {
          framingType: 'framing1'
        }
      }
    ]
  }
}

I want to ensure that:

  • If there are different moduleId values, I want: Only one module allowed
  • If there are different rack.framingType values, I want: Only one framing type allowed

I have this sort of started with:

Joi.object({
  drawingNode: Joi.object({
    moduleRackOutputs: Joi.array()
      .items(
        Joi.object().keys({
          moduleId: Joi.string().required(),
          tilt: Joi.string().required(),
          rack: Joi.object({
            framingType: Joi.string().required()
          })
        })
      )
      .unique((a, b) => a.moduleId !== b.moduleId)
      .messages({
        'array.unique':
          'The drawing contains more than one module type. Multiple module types are not yet supported by the PVsyst RPA.'
      })
  })
})

Which works for the module, but not the framingType. Seems I can't use multiple unique?

I'd love any help or pointers. Thanks!

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