-
Notifications
You must be signed in to change notification settings - Fork 0
/
poc.js
executable file
·49 lines (39 loc) · 1.07 KB
/
poc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
var Validator = require('jsonschema').Validator;
var baseSchema = require("./schemas/base.json");
function testAnswered() {
var eventSchema = require("./schemas/call/dialog/answered.json");
var v = new Validator();
var instance = {
"id": "1234",
"streamId": "abcd",
"subscriptionId": "5678abcd",
"type": "call.dialog.answered",
"payload": {
"requestUri": "[email protected]",
"uri": "[email protected]"
},
"createdAt": "2017-07-05T20:47:26+00:00"
};
v.addSchema(baseSchema);
console.log(v.validate(instance, eventSchema));
}
function testProduced() {
var eventSchema = require("./schemas/call/recording/uploaded.json");
var v = new Validator();
var instance = {
"id": "1234",
"streamId": "abcd",
"subscriptionId": "5678abcd",
"type": "call.recording.uploaded",
"payload": {
"service": "aws",
"bucket": "bogus"
},
"createdAt": "2017-07-05T20:47:26+00:00"
};
v.addSchema(baseSchema);
console.log(v.validate(instance, eventSchema));
}
testAnswered();
testProduced();