object but not array
how do we declare a schema that only accepts plain json object like
{}
or {some: "key"}
but not []
?5 Replies
this still accepts

I guess
Changing
unknown
to be whatever type you want all the values to adhere to (unknown
will allow anything, so if that's what you want then you can just leave)
There's also type.Record("string", "unknown")
, so you can use that if you prefer the syntaxThanks, I'll give that a shot
I would probably just write a narrow to check that it's not an array:
https://arktype.io/docs/expressions#narrow
What you want is essentially a negated type and typescript and can't be expressed well natively for the same reason with types.
A custom predicate is probably the way to go.