Skip to content

Commit d4ffd56

Browse files
Merge pull request #401 from json-schema-org/ether/format-uuid
tests for the "uuid" format
2 parents 08f6cda + 2d6c457 commit d4ffd56

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

tests/draft2019-09/format.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,5 +610,41 @@
610610
"valid": true
611611
}
612612
]
613+
},
614+
{
615+
"description": "validation of UUIDs",
616+
"schema": { "format": "uuid" },
617+
"tests": [
618+
{
619+
"description": "ignores integers",
620+
"data": 12,
621+
"valid": true
622+
},
623+
{
624+
"description": "ignores floats",
625+
"data": 13.7,
626+
"valid": true
627+
},
628+
{
629+
"description": "ignores objects",
630+
"data": {},
631+
"valid": true
632+
},
633+
{
634+
"description": "ignores arrays",
635+
"data": [],
636+
"valid": true
637+
},
638+
{
639+
"description": "ignores booleans",
640+
"data": false,
641+
"valid": true
642+
},
643+
{
644+
"description": "ignores null",
645+
"data": null,
646+
"valid": true
647+
}
648+
]
613649
}
614650
]
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[
2+
{
3+
"description": "uuid format",
4+
"schema": {
5+
"format": "uuid"
6+
},
7+
"tests": [
8+
{
9+
"description": "all upper-case",
10+
"data": "2EB8AA08-AA98-11EA-B4AA-73B441D16380",
11+
"valid": true
12+
},
13+
{
14+
"description": "all lower-case",
15+
"data": "2eb8aa08-aa98-11ea-b4aa-73b441d16380",
16+
"valid": true
17+
},
18+
{
19+
"description": "mixed case",
20+
"data": "2eb8aa08-AA98-11ea-B4Aa-73B441D16380",
21+
"valid": true
22+
},
23+
{
24+
"description": "all zeroes is valid",
25+
"data": "00000000-0000-0000-0000-000000000000",
26+
"valid": true
27+
},
28+
{
29+
"description": "wrong length",
30+
"data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638",
31+
"valid": false
32+
},
33+
{
34+
"description": "missing section",
35+
"data": "2eb8aa08-aa98-11ea-73b441d16380",
36+
"valid": false
37+
},
38+
{
39+
"description": "bad characters (not hex)",
40+
"data": "2eb8aa08-aa98-11ea-b4ga-73b441d16380",
41+
"valid": false
42+
},
43+
{
44+
"description": "no dashes",
45+
"data": "2eb8aa08aa9811eab4aa73b441d16380",
46+
"valid": false
47+
},
48+
{
49+
"description": "valid version 4",
50+
"data": "98d80576-482e-427f-8434-7f86890ab222",
51+
"valid": true
52+
},
53+
{
54+
"description": "valid version 5",
55+
"data": "99c17cbb-656f-564a-940f-1a4568f03487",
56+
"valid": true
57+
},
58+
{
59+
"description": "hypothetical version 6",
60+
"data": "99c17cbb-656f-664a-940f-1a4568f03487",
61+
"valid": true
62+
},
63+
{
64+
"description": "hypothetical version 15",
65+
"data": "99c17cbb-656f-f64a-940f-1a4568f03487",
66+
"valid": true
67+
}
68+
]
69+
}
70+
]

0 commit comments

Comments
 (0)