| 1 | import z, { ZodType } from 'zod' |
| 2 | |
| 3 | export type RangeFilter<T> = [T, T] | [undefined, T] | [T, undefined] |
| 4 | |
| 5 | export function createRangeFilter<TOutput = unknown, TInput = TOutput>(schema: ZodType<TOutput, TInput>): ZodType<RangeFilter<TOutput>> { |
| 6 | return z.union([ |
| 7 | z.tuple([schema, schema]), |
| 8 | z.tuple([z.undefined(), schema]), |
| 9 | z.tuple([schema, z.undefined()]), |
| 10 | ]) |
| 11 | } |
| 12 |