FormidableLabs / groqd

A schema-unaware, runtime and type-safe query builder for GROQ.
https://commerce.nearform.com/open-source/groqd
MIT License
221 stars 17 forks source link

ZOD enums support #289

Open reapziq opened 1 month ago

reapziq commented 1 month ago

Is there an existing issue for this?

Code of Conduct

Feature Request

Whenever I need to validate that a queried string is of an allowed set of values, I currently use a combination of q.union and q.literal, e.g. q.union([q.literal('exact'), q.literal('approximate')]). The query itself is (as expected) not affected by this, so it's just about narrowing the queried type. Would it be complicated to add native support for ZOD enums similarly to literal, or am I missing a way to chain q calls with z validators to narrow down the queried type? Thank you!