import { Try } from '@oats-ts/try' import { ValidatorConfig } from '@oats-ts/validators' import { QueryOptions, PrimitiveRecord, FieldParsers, RawQueryParams, QueryValueDeserializer } from '../types' import { queryFormObjectExplode } from './queryFormObjectExplode' import { queryFormObjectNoExplode } from './queryFormObjectNoExplode' export const queryFormObject = (parsers: FieldParsers, opts: QueryOptions = {}): QueryValueDeserializer => (data: RawQueryParams, name: string, path: string, config: ValidatorConfig): Try => { const options: QueryOptions = { explode: true, ...opts } const delegate = options.explode ? queryFormObjectExplode : queryFormObjectNoExplode return delegate(parsers, options, name, path, data, config) }