Skip to content

Commit 8e4aad9

Browse files
leif.rilbeleif.rilbe
authored andcommitted
Test cases for propertyNames with pattern.
1 parent 8daea3f commit 8e4aad9

File tree

3 files changed

+177
-0
lines changed

3 files changed

+177
-0
lines changed

tests/draft2019-09/propertyNames.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,65 @@
4343
}
4444
]
4545
},
46+
{
47+
"description": "propertyNames validation with pattern for camelCase",
48+
"schema": {
49+
"propertyNames": { "pattern": "^[a-z]+([A-Z][a-z]+)*$" }
50+
},
51+
"tests": [
52+
{
53+
"description": "all property names valid",
54+
"data": {
55+
"f": {},
56+
"foo": {},
57+
"foobar": {},
58+
"fooBar": {}
59+
},
60+
"valid": true
61+
},
62+
{
63+
"description": "property name with leading capital letter is invalid",
64+
"data": {
65+
"Foo": {}
66+
},
67+
"valid": false
68+
},
69+
{
70+
"description": "property name with adjacent capital letters is invalid",
71+
"data": {
72+
"fOO": {}
73+
},
74+
"valid": false
75+
},
76+
{
77+
"description": "property name with digit is invalid",
78+
"data": {
79+
"foo1": {}
80+
},
81+
"valid": false
82+
},
83+
{
84+
"description": "object without properties is valid",
85+
"data": {},
86+
"valid": true
87+
},
88+
{
89+
"description": "ignores arrays",
90+
"data": [1, 2, 3, 4],
91+
"valid": true
92+
},
93+
{
94+
"description": "ignores strings",
95+
"data": "foobar",
96+
"valid": true
97+
},
98+
{
99+
"description": "ignores other non-objects",
100+
"data": 12,
101+
"valid": true
102+
}
103+
]
104+
},
46105
{
47106
"description": "propertyNames with boolean schema true",
48107
"schema": {"propertyNames": true},

tests/draft6/propertyNames.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,65 @@
4343
}
4444
]
4545
},
46+
{
47+
"description": "propertyNames validation with pattern for camelCase",
48+
"schema": {
49+
"propertyNames": { "pattern": "^[a-z]+([A-Z][a-z]+)*$" }
50+
},
51+
"tests": [
52+
{
53+
"description": "all property names valid",
54+
"data": {
55+
"f": {},
56+
"foo": {},
57+
"foobar": {},
58+
"fooBar": {}
59+
},
60+
"valid": true
61+
},
62+
{
63+
"description": "property name with leading capital letter is invalid",
64+
"data": {
65+
"Foo": {}
66+
},
67+
"valid": false
68+
},
69+
{
70+
"description": "property name with adjacent capital letters is invalid",
71+
"data": {
72+
"fOO": {}
73+
},
74+
"valid": false
75+
},
76+
{
77+
"description": "property name with digit is invalid",
78+
"data": {
79+
"foo1": {}
80+
},
81+
"valid": false
82+
},
83+
{
84+
"description": "object without properties is valid",
85+
"data": {},
86+
"valid": true
87+
},
88+
{
89+
"description": "ignores arrays",
90+
"data": [1, 2, 3, 4],
91+
"valid": true
92+
},
93+
{
94+
"description": "ignores strings",
95+
"data": "foobar",
96+
"valid": true
97+
},
98+
{
99+
"description": "ignores other non-objects",
100+
"data": 12,
101+
"valid": true
102+
}
103+
]
104+
},
46105
{
47106
"description": "propertyNames with boolean schema true",
48107
"schema": {"propertyNames": true},

tests/draft7/propertyNames.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,65 @@
4343
}
4444
]
4545
},
46+
{
47+
"description": "propertyNames validation with pattern for camelCase",
48+
"schema": {
49+
"propertyNames": { "pattern": "^[a-z]+([A-Z][a-z]+)*$" }
50+
},
51+
"tests": [
52+
{
53+
"description": "all property names valid",
54+
"data": {
55+
"f": {},
56+
"foo": {},
57+
"foobar": {},
58+
"fooBar": {}
59+
},
60+
"valid": true
61+
},
62+
{
63+
"description": "property name with leading capital letter is invalid",
64+
"data": {
65+
"Foo": {}
66+
},
67+
"valid": false
68+
},
69+
{
70+
"description": "property name with adjacent capital letters is invalid",
71+
"data": {
72+
"fOO": {}
73+
},
74+
"valid": false
75+
},
76+
{
77+
"description": "property name with digit is invalid",
78+
"data": {
79+
"foo1": {}
80+
},
81+
"valid": false
82+
},
83+
{
84+
"description": "object without properties is valid",
85+
"data": {},
86+
"valid": true
87+
},
88+
{
89+
"description": "ignores arrays",
90+
"data": [1, 2, 3, 4],
91+
"valid": true
92+
},
93+
{
94+
"description": "ignores strings",
95+
"data": "foobar",
96+
"valid": true
97+
},
98+
{
99+
"description": "ignores other non-objects",
100+
"data": 12,
101+
"valid": true
102+
}
103+
]
104+
},
46105
{
47106
"description": "propertyNames with boolean schema true",
48107
"schema": {"propertyNames": true},

0 commit comments

Comments
 (0)