Debian Codegraph @

test/tests/05 - Objects/05 - additionalProperties.js

raw symbols SCIP
1 describe("Objects 05", function () {
2
3 it("additionalProperties schema success", function () {
4 var data = {intKey: 1, intKey2: 5, stringKey: "string"};
5 var schema = {
6 properties: {
7 intKey: {"type": "integer"}
8 },
9 patternProperties: {
10 "^int": {minimum: 0}
11 },
12 additionalProperties: {"type": "string"}
13 };
14 var valid = tv4.validate(data, schema);
15 assert.isTrue(valid);
16 });
17
18 it("patternProperties schema failure", function () {
19 var data = {intKey: 10, intKey2: 5, stringKey: null};
20 var schema = {
21 properties: {
22 intKey: {minimum: 5}
23 },
24 patternProperties: {
25 "^int": {"type": "integer"}
26 },
27 additionalProperties: {"type": "string"}
28 };
29 var valid = tv4.validate(data, schema);
30 assert.isFalse(valid);
31 });
32
33 it("patternProperties boolean success", function () {
34 var data = {intKey: 10, intKey2: 5, stringKey: null};
35 var schema = {
36 properties: {
37 intKey: {minimum: 5}
38 },
39 patternProperties: {
40 "^int": {"type": "integer"}
41 },
42 additionalProperties: true
43 };
44 var valid = tv4.validate(data, schema);
45 assert.isTrue(valid);
46 });
47
48 it("patternProperties boolean failure", function () {
49 var data = {intKey: 10, intKey2: 5, stringKey: null};
50 var schema = {
51 properties: {
52 intKey: {minimum: 5}
53 },
54 patternProperties: {
55 "^int": {"type": "integer"}
56 },
57 additionalProperties: false
58 };
59 var valid = tv4.validate(data, schema);
60 assert.isFalse(valid);
61 });
62 });