groqd icon indicating copy to clipboard operation
groqd copied to clipboard

ZOD enums support

Open reapziq opened this issue 8 months ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Code of Conduct

  • [X] I agree to follow this project's 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!

reapziq avatar May 31 '24 20:05 reapziq