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:
- The array must have at least one value (
.required() ✅)
- Each array item must be an object of a given shape (
.items() ✅)
- 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?
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:
.required()✅).items()✅)nameproperty valueBecause 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
itemdefinition, errors become the genericdoes 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?