Skip to content

Commit 05fdba4

Browse files
author
Evgeny Poberezkin
authored
Merge pull request #173 from epoberezkin/format
Draft-06 formats
2 parents bc4de6c + e8ef6fd commit 05fdba4

File tree

3 files changed

+112
-2
lines changed

3 files changed

+112
-2
lines changed

index.js

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

1717
function runTest(draft) {
18-
var opts = {};
18+
var opts = {format: 'full'};
1919
if (draft == 4) opts.meta = false;
2020
var ajv = new Ajv(opts);
2121
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme",
2323
"devDependencies": {
24-
"ajv": "^5.0.4-beta.0",
24+
"ajv": "^5.0.4-beta.1",
2525
"json-schema-test": "^1.3.0",
2626
"mocha": "^3.2.0"
2727
}

tests/draft6/optional/format.json

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"data": "//foo.bar/?baz=qux#quux",
3535
"valid": false
3636
},
37+
{
38+
"description": "an invalid relative URI Reference",
39+
"data": "/abc",
40+
"valid": false
41+
},
3742
{
3843
"description": "an invalid URI",
3944
"data": "\\\\WINDOWS\\fileshare",
@@ -46,6 +51,75 @@
4651
}
4752
]
4853
},
54+
{
55+
"description": "validation of URI References",
56+
"schema": {"format": "uri-reference"},
57+
"tests": [
58+
{
59+
"description": "a valid URI",
60+
"data": "http://foo.bar/?baz=qux#quux",
61+
"valid": true
62+
},
63+
{
64+
"description": "a valid protocol-relative URI Reference",
65+
"data": "//foo.bar/?baz=qux#quux",
66+
"valid": true
67+
},
68+
{
69+
"description": "a valid relative URI Reference",
70+
"data": "/abc",
71+
"valid": true
72+
},
73+
{
74+
"description": "an invalid URI Reference",
75+
"data": "\\\\WINDOWS\\fileshare",
76+
"valid": false
77+
},
78+
{
79+
"description": "a valid URI Reference",
80+
"data": "abc",
81+
"valid": true
82+
},
83+
{
84+
"description": "a valid URI fragment",
85+
"data": "#fragment",
86+
"valid": true
87+
},
88+
{
89+
"description": "an invalid URI fragment",
90+
"data": "#frag\\ment",
91+
"valid": false
92+
}
93+
]
94+
},
95+
{
96+
"description": "format: uri-template",
97+
"schema": {
98+
"format": "uri-template"
99+
},
100+
"tests": [
101+
{
102+
"description": "a valid uri-template",
103+
"data": "http://example.com/dictionary/{term:1}/{term}",
104+
"valid": true
105+
},
106+
{
107+
"description": "an invalid uri-template",
108+
"data": "http://example.com/dictionary/{term:1}/{term",
109+
"valid": false
110+
},
111+
{
112+
"description": "a valid uri-template without variables",
113+
"data": "http://example.com/dictionary",
114+
"valid": true
115+
},
116+
{
117+
"description": "a valid relative uri-template",
118+
"data": "dictionary/{term:1}/{term}",
119+
"valid": true
120+
}
121+
]
122+
},
49123
{
50124
"description": "validation of e-mail addresses",
51125
"schema": {"format": "email"},
@@ -144,5 +218,41 @@
144218
"valid": false
145219
}
146220
]
221+
},
222+
{
223+
"description": "validation of JSON-pointers",
224+
"schema": {"format": "json-pointer"},
225+
"tests": [
226+
{
227+
"description": "a valid JSON-pointer",
228+
"data": "/foo/bar~0/baz~1/%a",
229+
"valid": true
230+
},
231+
{
232+
"description": "empty string is valid",
233+
"data": "",
234+
"valid": true
235+
},
236+
{
237+
"description": "/ is valid",
238+
"data": "/",
239+
"valid": true
240+
},
241+
{
242+
"description": "not a valid JSON-pointer (~ not escaped)",
243+
"data": "/foo/bar~",
244+
"valid": false
245+
},
246+
{
247+
"description": "valid JSON-pointer with empty segment",
248+
"data": "/foo//bar",
249+
"valid": true
250+
},
251+
{
252+
"description": "valid JSON-pointer with the last empty segment",
253+
"data": "/foo/bar/",
254+
"valid": true
255+
}
256+
]
147257
}
148258
]

0 commit comments

Comments
 (0)