Tuesday, 11 January 2022

How can I ensure that an array of objects contains only one of a particular key with Joi?

I have something like:

  let moduleId

  moduleRackOutputs.forEach((output) => {
    if (!moduleId) {
      moduleId = output.moduleId
    } else if (output.moduleId !== moduleId) {
      errors.add([
        'The drawing contains more than one module type. Multiple module types are not yet supported by the PVsyst RPA.'
      ])
    }
  })

I want to convert this to a Joi schema. How would I accomplish this?

Thank you



from How can I ensure that an array of objects contains only one of a particular key with Joi?

No comments:

Post a Comment