tighten zod validation for segment parameters
Some checks are pending
Node.js CI / build (push) Waiting to run

This commit is contained in:
Francis Cao 2026-01-22 12:53:44 -08:00
parent 6fd428683d
commit d4ff7c8e3f
2 changed files with 38 additions and 2 deletions

View file

@ -104,6 +104,23 @@ export const reportTypeParam = z.enum([
'utm',
]);
export const operatorParam = z.enum([
'eq',
'neq',
's',
'ns',
'c',
'dnc',
't',
'f',
'gt',
'lt',
'gte',
'lte',
'bf',
'af',
]);
export const goalReportSchema = z.object({
type: z.literal('goal'),
parameters: z
@ -231,3 +248,22 @@ export const reportResultSchema = z.intersection(
);
export const segmentTypeParam = z.enum(['segment', 'cohort']);
export const segmentParametersSchema = z.object({
filters: z
.array(
z.object({
name: z.string(),
operator: operatorParam,
value: z.string(),
}),
)
.optional(),
dateRange: z.string().optional(),
action: z
.object({
type: z.string(),
value: z.string(),
})
.optional(),
});