Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const createQuery = (opts: CollectionQueryValidatorOpts) =>
t.partial({
sortBy: t.union(opts.sortBy.map(s => t.literal(s)) as any),
sortDir: t.union([
t.refinement(t.union([t.string, t.number]), n => Number(n) === SortDir.ASC, 'SortDir.ASC'),
t.refinement(t.union([t.string, t.number]), n => Number(n) === SortDir.DESC, 'SortDir.DESC'),
]),
limit: t.refinement(t.union([t.string, t.number]), n => Number(n) >= 0, 'number.0+'),
page: t.refinement(t.union([t.string, t.number]), n => Number(n) >= 1, 'number.1+'),
});