Skip to content

Complex array validation requirements #1656

@erquhart

Description

@erquhart

Wondering if there's a simple approach here that I'm missing, maybe some part of the API designed to serve a use case like mine. Validation for the array in question should work like this:

  1. The array must have at least one value (.required() ✅)
  2. Each array item must be an object of a given shape (.items() ✅)
  3. One of the array items must have a value from a list as it's name property value

Because there is only one shape for the objects in the array, we enjoy the ability to provide detailed error messages about how an individual object in the array failed. If we use a second item definition, errors become the generic does not match any of the allowed types.

Is there any way to validate as described without losing specific error messaging for the objects in the array?

Metadata

Metadata

Assignees

Labels

supportQuestions, discussions, and general support

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions