Skip to content

Commit be19a54

Browse files
committed
Squashed 'json/' changes from 27f8c84..9567c58
9567c58 Merge pull request #189 from blackivory86/uri_formats 1066f7f Merge pull request #192 from furstenheim/master 0b71ddd Update README.md 82db537 Merge pull request #191 from korzio/master 1aecb7b feat(const): Add validation tests for arrays b9d4dbd set unique descriptions for test-cases aaa3ef7 adds more valid and invalid URI testcases 728066f Merge pull request #188 from json-schema-org/sequences-and-objects c47341a Flesh out some more ignore cases for object validators. f339360 make test descriptions unique and no longer than 60 chars 6820a83 Merge branch 'CroniD-master' aaa32d8 test: update "json-pointer" format to exclude fragments 85a552f added some more tests for json-pointer format b7b79fc extended tests for json-pointer format git-subtree-dir: json git-subtree-split: 9567c588bc9d1705b4840ee9d9f3f268f40c1e68
1 parent 8bff7e3 commit be19a54

24 files changed

+506
-36
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ for more information.
155155
### PostgreSQL ###
156156

157157
* [postgres-json-schema](https://github.com/gavinwahl/postgres-json-schema)
158+
* [is_jsonb_valid](https://github.com/furstenheim/is_jsonb_valid)
158159

159160
If you use it as well, please fork and send a pull request adding yourself to
160161
the list :).

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ runTest(4);
1515
runTest(6);
1616

1717
function runTest(draft) {
18-
var opts = {format: 'full'};
18+
var opts = {
19+
format: 'full',
20+
formats: {'json-pointer': /^(?:\/(?:[^~\/]|~0|~1)*)*$/}
21+
};
1922
if (draft == 4) opts.meta = false;
2023
var ajv = new Ajv(opts);
2124
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));

tests/draft3/additionalProperties.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@
1919
"valid": false
2020
},
2121
{
22-
"description": "ignores non-objects",
22+
"description": "ignores arrays",
2323
"data": [1, 2, 3],
2424
"valid": true
2525
},
26+
{
27+
"description": "ignores strings",
28+
"data": "foobarbaz",
29+
"valid": true
30+
},
31+
{
32+
"description": "ignores other non-objects",
33+
"data": 12,
34+
"valid": true
35+
},
2636
{
2737
"description": "patternProperties are not additional properties",
2838
"data": {"foo":1, "vroom": 2},

tests/draft3/dependencies.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,18 @@
2626
"valid": false
2727
},
2828
{
29-
"description": "ignores non-objects",
30-
"data": "foo",
29+
"description": "ignores arrays",
30+
"data": ["bar"],
31+
"valid": true
32+
},
33+
{
34+
"description": "ignores strings",
35+
"data": "foobar",
36+
"valid": true
37+
},
38+
{
39+
"description": "ignores other non-objects",
40+
"data": 12,
3141
"valid": true
3242
}
3343
]

tests/draft3/patternProperties.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
"valid": false
3030
},
3131
{
32-
"description": "ignores non-objects",
32+
"description": "ignores arrays",
33+
"data": [],
34+
"valid": true
35+
},
36+
{
37+
"description": "ignores other non-objects",
3338
"data": 12,
3439
"valid": true
3540
}

tests/draft3/properties.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@
2929
"valid": true
3030
},
3131
{
32-
"description": "ignores non-objects",
32+
"description": "ignores arrays",
3333
"data": [],
3434
"valid": true
35+
},
36+
{
37+
"description": "ignores other non-objects",
38+
"data": 12,
39+
"valid": true
3540
}
3641
]
3742
},

tests/draft4/additionalProperties.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@
1919
"valid": false
2020
},
2121
{
22-
"description": "ignores non-objects",
22+
"description": "ignores arrays",
2323
"data": [1, 2, 3],
2424
"valid": true
2525
},
26+
{
27+
"description": "ignores strings",
28+
"data": "foobarbaz",
29+
"valid": true
30+
},
31+
{
32+
"description": "ignores other non-objects",
33+
"data": 12,
34+
"valid": true
35+
},
2636
{
2737
"description": "patternProperties are not additional properties",
2838
"data": {"foo":1, "vroom": 2},

tests/draft4/dependencies.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,18 @@
2626
"valid": false
2727
},
2828
{
29-
"description": "ignores non-objects",
30-
"data": "foo",
29+
"description": "ignores arrays",
30+
"data": ["bar"],
31+
"valid": true
32+
},
33+
{
34+
"description": "ignores strings",
35+
"data": "foobar",
36+
"valid": true
37+
},
38+
{
39+
"description": "ignores other non-objects",
40+
"data": 12,
3141
"valid": true
3242
}
3343
]

tests/draft4/maxProperties.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@
1919
"valid": false
2020
},
2121
{
22-
"description": "ignores non-objects",
22+
"description": "ignores arrays",
23+
"data": [1, 2, 3],
24+
"valid": true
25+
},
26+
{
27+
"description": "ignores strings",
2328
"data": "foobar",
2429
"valid": true
30+
},
31+
{
32+
"description": "ignores other non-objects",
33+
"data": 12,
34+
"valid": true
2535
}
2636
]
2737
}

tests/draft4/minProperties.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@
1919
"valid": false
2020
},
2121
{
22-
"description": "ignores non-objects",
22+
"description": "ignores arrays",
23+
"data": [],
24+
"valid": true
25+
},
26+
{
27+
"description": "ignores strings",
2328
"data": "",
2429
"valid": true
30+
},
31+
{
32+
"description": "ignores other non-objects",
33+
"data": 12,
34+
"valid": true
2535
}
2636
]
2737
}

tests/draft4/optional/format.json

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,80 @@
2525
"schema": {"format": "uri"},
2626
"tests": [
2727
{
28-
"description": "a valid URI",
28+
"description": "a valid URL with anchor tag",
2929
"data": "http://foo.bar/?baz=qux#quux",
3030
"valid": true
3131
},
32+
{
33+
"description": "a valid URL with anchor tag and parantheses",
34+
"data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
35+
"valid": true
36+
},
37+
{
38+
"description": "a valid URL with URL-encoded stuff",
39+
"data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
40+
"valid": true
41+
},
42+
{
43+
"description": "a valid puny-coded URL ",
44+
"data": "http://xn--nw2a.xn--j6w193g/",
45+
"valid": true
46+
},
47+
{
48+
"description": "a valid URL with many special characters",
49+
"data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
50+
"valid": true
51+
},
52+
{
53+
"description": "a valid URL based on IPv4",
54+
"data": "http://223.255.255.254",
55+
"valid": true
56+
},
57+
{
58+
"description": "a valid URL with ftp scheme",
59+
"data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
60+
"valid": true
61+
},
62+
{
63+
"description": "a valid URL for a simple text file",
64+
"data": "http://www.ietf.org/rfc/rfc2396.txt",
65+
"valid": true
66+
},
67+
{
68+
"description": "a valid URL ",
69+
"data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
70+
"valid": true
71+
},
72+
{
73+
"description": "a valid mailto URI",
74+
"data": "mailto:[email protected]",
75+
"valid": true
76+
},
77+
{
78+
"description": "a valid newsgroup URI",
79+
"data": "news:comp.infosystems.www.servers.unix",
80+
"valid": true
81+
},
82+
{
83+
"description": "a valid tel URI",
84+
"data": "tel:+1-816-555-1212",
85+
"valid": true
86+
},
87+
{
88+
"description": "a valid URN",
89+
"data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
90+
"valid": true
91+
},
3292
{
3393
"description": "an invalid protocol-relative URI Reference",
3494
"data": "//foo.bar/?baz=qux#quux",
3595
"valid": false
3696
},
97+
{
98+
"description": "an invalid relative URI Reference",
99+
"data": "/abc",
100+
"valid": false
101+
},
37102
{
38103
"description": "an invalid URI",
39104
"data": "\\\\WINDOWS\\fileshare",
@@ -43,6 +108,16 @@
43108
"description": "an invalid URI though valid URI reference",
44109
"data": "abc",
45110
"valid": false
111+
},
112+
{
113+
"description": "an invalid URI with spaces",
114+
"data": "http:// shouldfail.com",
115+
"valid": false
116+
},
117+
{
118+
"description": "an invalid URI with spaces and missing scheme",
119+
"data": ":// should fail",
120+
"valid": false
46121
}
47122
]
48123
},

tests/draft4/patternProperties.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,17 @@
2929
"valid": false
3030
},
3131
{
32-
"description": "ignores non-objects",
32+
"description": "ignores arrays",
33+
"data": [],
34+
"valid": true
35+
},
36+
{
37+
"description": "ignores strings",
38+
"data": "",
39+
"valid": true
40+
},
41+
{
42+
"description": "ignores other non-objects",
3343
"data": 12,
3444
"valid": true
3545
}

tests/draft4/properties.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@
2929
"valid": true
3030
},
3131
{
32-
"description": "ignores non-objects",
32+
"description": "ignores arrays",
3333
"data": [],
3434
"valid": true
35+
},
36+
{
37+
"description": "ignores other non-objects",
38+
"data": 12,
39+
"valid": true
3540
}
3641
]
3742
},

tests/draft4/required.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@
2020
"valid": false
2121
},
2222
{
23-
"description": "ignores non-objects",
23+
"description": "ignores arrays",
24+
"data": [],
25+
"valid": true
26+
},
27+
{
28+
"description": "ignores strings",
29+
"data": "",
30+
"valid": true
31+
},
32+
{
33+
"description": "ignores other non-objects",
2434
"data": 12,
2535
"valid": true
2636
}

tests/draft6/additionalProperties.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@
1919
"valid": false
2020
},
2121
{
22-
"description": "ignores non-objects",
22+
"description": "ignores arrays",
2323
"data": [1, 2, 3],
2424
"valid": true
2525
},
26+
{
27+
"description": "ignores strings",
28+
"data": "foobarbaz",
29+
"valid": true
30+
},
31+
{
32+
"description": "ignores other non-objects",
33+
"data": 12,
34+
"valid": true
35+
},
2636
{
2737
"description": "patternProperties are not additional properties",
2838
"data": {"foo":1, "vroom": 2},

tests/draft6/const.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@
4646
}
4747
]
4848
},
49+
{
50+
"description": "const with array",
51+
"schema": {"const": [{ "foo": "bar" }]},
52+
"tests": [
53+
{
54+
"description": "same array is valid",
55+
"data": [{"foo": "bar"}],
56+
"valid": true
57+
},
58+
{
59+
"description": "another array item is invalid",
60+
"data": [2],
61+
"valid": false
62+
},
63+
{
64+
"description": "array with additional items is invalid",
65+
"data": [1, 2, 3],
66+
"valid": false
67+
}
68+
]
69+
},
4970
{
5071
"description": "const with null",
5172
"schema": {"const": null},

0 commit comments

Comments
 (0)