-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web-analytics): validate web analytics filters from url (#19967)
* fix(web-analytics): validate web analytics filters from url * Hide warning * Import order
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Ajv from 'ajv' | ||
|
||
import { WebAnalyticsPropertyFilters } from '~/queries/schema' | ||
|
||
import schema from './schema.json' | ||
const ajv = new Ajv({ | ||
allowUnionTypes: true, | ||
}) | ||
ajv.addSchema(schema) | ||
|
||
export const isWebAnalyticsPropertyFilters = (data: unknown): data is WebAnalyticsPropertyFilters => { | ||
const validator = ajv.getSchema('#/definitions/WebAnalyticsPropertyFilters') | ||
if (!validator) { | ||
throw new Error('Could not find validator for WebAnalyticsPropertyFilters') | ||
} | ||
return validator(data) as boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters