Skip to content

Instantly share code, notes, and snippets.

@rdpanek
Created August 6, 2014 11:36
Show Gist options
  • Save rdpanek/2f2c146613a6a1a67ffa to your computer and use it in GitHub Desktop.
Save rdpanek/2f2c146613a6a1a67ffa to your computer and use it in GitHub Desktop.
tv4 = require 'tv4'
result =
data:
items: [
values: [
A: "2014-02-01 00:00:00"
B:
"link clicks": 38993
"other clicks": 37192
"photo view": 5969
"video play": 12
]
aggregate:
B:
simple:
avg: 190
sum: 570
min_abs: [["2014-02-01 00:00:00", 108]]
max_abs: [["2014-04-01 00:00:00", 250]]
id: "78569316"
type: "tw-profile"
timeFrom: "2014-02-01"
timeTo: "2014-04-30"
]
schema =
title: 'fbBenchmark-results'
type: 'object'
properties:
data:
type: 'object'
required: yes
properties:
items:
type: 'array'
required: yes
items: [
type: 'object'
properties:
values:
type: 'array'
items: [
]
additionalItems:
required: yes
type: 'object'
properties:
A:
type: 'string'
required: yes
B:
type: ['object', 'null']
required: yes
properties:
'link clicks':
type: 'number'
'other clicks':
type: 'number'
required: [
"link clicks"
"other clicks"
"photo view"
"video play"
]
]
valid = tv4.validate result, schema
console.log tv4.error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment