Skip to content

Data validation: validate Array of objects have a specific structure #288

Open
@humitos

Description

@humitos

I found myself want to validate the object items included into an Array. However, I didn't find a quick way to do it while working on #281 so I wrote a TODO comment there.

A small example of what I want is on the versions.active field:

    versions: {
      type: "object",
      required: ["current", "active"],
      properties: {
        active: {
          type: "array",
          // TODO: validate each item of the array has the following structure
          //
          // items: { type: "object" },
          // required: ["slug", "urls"],
          // properties: {
          //   slug: { type: "string" },
          //   urls: {
          //     type: "object",
          //     required: ["documentation"],
          //     properties: {
          //       documentation: { type: "string" },
          //     },
          //   },
          // },
        },

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImprovementMinor improvement to code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions