mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Fixed report validations.
This commit is contained in:
parent
530d6fb323
commit
6ab7746b7d
2 changed files with 19 additions and 10 deletions
|
|
@ -10,16 +10,23 @@ export async function POST(request: Request) {
|
|||
...reportParms,
|
||||
goals: z
|
||||
.array(
|
||||
z.object({
|
||||
type: z.string().regex(/url|event|event-data/),
|
||||
value: z.string(),
|
||||
goal: z.number(),
|
||||
operator: z
|
||||
.string()
|
||||
.regex(/count|sum|average/)
|
||||
.refine(data => data['type'] === 'event-data'),
|
||||
property: z.string().refine(data => data['type'] === 'event-data'),
|
||||
}),
|
||||
z
|
||||
.object({
|
||||
type: z.string().regex(/url|event|event-data/),
|
||||
value: z.string(),
|
||||
goal: z.coerce.number(),
|
||||
operator: z
|
||||
.string()
|
||||
.regex(/count|sum|average/)
|
||||
.optional(),
|
||||
property: z.string().optional(),
|
||||
})
|
||||
.refine(data => {
|
||||
if (data['type'] === 'event-data') {
|
||||
return data['operator'] && data['property'];
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
)
|
||||
.min(1),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import { getReports, createReport } from 'queries';
|
|||
|
||||
export async function GET(request: Request) {
|
||||
const schema = z.object({
|
||||
websiteId: z.string().uuid().optional(),
|
||||
teamId: z.string().uuid().optional(),
|
||||
...pagingParams,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue