ianstormtaylor / superstruct

A simple and composable way to validate data in JavaScript (and TypeScript).
https://docs.superstructjs.org
MIT License
7.02k stars 224 forks source link

The "struct.validator is not a function" when validating an array of structs #998

Closed DZakh closed 2 years ago

DZakh commented 2 years ago

Reproduced on superstruct version 0.15.3

I have a struct:

const applicationStruct = s.object({ status: s.number() })
s.object({
  applications: s.array(applicationStruct),
})

And when I call validation on it I get the "struct.validator is not a function" TypeError

image

DZakh commented 2 years ago

My bad. I used union instead of enums.

status: s.enums(Object.values(APPLICATION_STATUSES))