-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
37 additions
and
5 deletions.
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
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,30 @@ | ||
import ajv from 'ajv' | ||
import rumEventsFormatJson from '../../../../rum-events-format/rum-events-format.json' | ||
import _commonSchemaJson from '../../../../rum-events-format/schemas/_common-schema.json' | ||
import actionSchemaJson from '../../../../rum-events-format/schemas/action-schema.json' | ||
import errorSchemaJson from '../../../../rum-events-format/schemas/error-schema.json' | ||
import long_taskSchemaJson from '../../../../rum-events-format/schemas/long_task-schema.json' | ||
import resourceSchemaJson from '../../../../rum-events-format/schemas/resource-schema.json' | ||
import viewSchemaJson from '../../../../rum-events-format/schemas/view-schema.json' | ||
import { ServerRumEvent } from '../types/serverEvents' | ||
|
||
export function validateFormat(events: ServerRumEvent[]) { | ||
events.forEach((event) => { | ||
const instance = new ajv({ | ||
allErrors: true, | ||
}) | ||
instance | ||
.addSchema(_commonSchemaJson, 'schemas/_common-schema.json') | ||
.addSchema(viewSchemaJson, 'schemas/view-schema.json') | ||
.addSchema(actionSchemaJson, 'schemas/action-schema.json') | ||
.addSchema(resourceSchemaJson, 'schemas/resource-schema.json') | ||
.addSchema(long_taskSchemaJson, 'schemas/long_task-schema.json') | ||
.addSchema(errorSchemaJson, 'schemas/error-schema.json') | ||
.addSchema(rumEventsFormatJson, 'rum-events-format.json') | ||
.validate('rum-events-format.json', event) | ||
|
||
if (instance.errors) { | ||
instance.errors.map((error) => fail(`${error.dataPath || 'event'} ${error.message}`)) | ||
} | ||
}) | ||
} |
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
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
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