Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schemas/rum/view-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"readOnly": true
},
"view": {
"type": "object",
"required": ["time_spent", "action", "error", "resource"],
"properties": {
"time_spent": { "type": "integer" },
Expand Down
13 changes: 12 additions & 1 deletion scripts/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,26 @@ function validateSchemasIds() {

function validateSamples() {
const ajv = new Ajv({
strict: true,
// By default, ajv objects to heterogeneous tuples; the reasoning is that
// they are awkward to work with in some languages. Disable this warning
// since we're using this feature extensively and are aware of the tradeoffs.
strictTuples: false,
allowUnionTypes: true,
})
forEachFile(SCHEMAS_DIRECTORY, (schemaPath) => ajv.addSchema(readJson(schemaPath)))
forEachFile(SAMPLES_DIRECTORY, (samplePath) => {
const schemaId = computeSchemaIdFromSamplePath(samplePath)
const valid = ajv.validate(schemaId, readJson(samplePath))
let valid
try {
valid = ajv.validate(schemaId, readJson(samplePath))
} catch (error) {
console.log(`❌ ${samplePath} had a validation error against ${schemaId}:`)
console.log(` - ${error.message}`)
process.exitCode = 1
return
}

if (valid) {
console.log(`✅ ${samplePath}`)
} else {
Expand Down
Loading