1
+ [
2
+ {
3
+ "description" : " Tests that validate custom message functionality where overrides can be provided at schema level for individual keywords" ,
4
+ "schema" : {
5
+ "type" : " object" ,
6
+ "properties" : {
7
+ "foo" : {
8
+ "type" : " array" ,
9
+ "maxItems" : 3 ,
10
+ "items" : {
11
+ "type" : " number"
12
+ },
13
+ "message" : {
14
+ "maxItems" : " Custom Message: Maximum 3 numbers can be given in 'foo'" ,
15
+ "type" : " Custom Message: Only numbers are supported in 'foo'"
16
+ }
17
+ },
18
+ "bar" : {
19
+ "type" : " string"
20
+ }
21
+ },
22
+ "message" : {
23
+ "type" : " Custom Message: Invalid type provided"
24
+ }
25
+ },
26
+ "tests" : [
27
+ {
28
+ "description" : " Basic Success Test 1" ,
29
+ "data" : {
30
+ "foo" : [],
31
+ "bar" : " Bar 1"
32
+ },
33
+ "valid" : true
34
+ },
35
+ {
36
+ "description" : " Basic Success Test 2" ,
37
+ "data" : {
38
+ "foo" : [1 , 2 ],
39
+ "bar" : " Bar 1"
40
+ },
41
+ "valid" : true
42
+ },
43
+ {
44
+ "description" : " Custom error message for keyword failing at top level - type keyword" ,
45
+ "data" : {
46
+ "foo" : [1 , 2 , 3 ],
47
+ "bar" : 123
48
+ },
49
+ "valid" : false ,
50
+ "validationMessages" : [
51
+ " Custom Message: Invalid type provided"
52
+ ]
53
+ },
54
+ {
55
+ "description" : " Custom error message for keyword failing at nested property level - type keyword" ,
56
+ "data" : {
57
+ "foo" : [1 , 2 , " text" ],
58
+ "bar" : " Bar 1"
59
+ },
60
+ "valid" : false ,
61
+ "validationMessages" : [
62
+ " Custom Message: Only numbers are supported in 'foo'"
63
+ ]
64
+ },
65
+ {
66
+ "description" : " Custom error message for keyword failing at nested property level - maxItems keyword" ,
67
+ "data" : {
68
+ "foo" : [1 , 2 , 3 , 4 ],
69
+ "bar" : " Bar 1"
70
+ },
71
+ "valid" : false ,
72
+ "validationMessages" : [
73
+ " Custom Message: Maximum 3 numbers can be given in 'foo'"
74
+ ]
75
+ },
76
+ {
77
+ "description" : " Custom error message for keyword failing at both top level and nested property level - type keyword" ,
78
+ "data" : {
79
+ "foo" : [1 , 2 , " text" ],
80
+ "bar" : 123
81
+ },
82
+ "valid" : false ,
83
+ "validationMessages" : [
84
+ " Custom Message: Invalid type provided" ,
85
+ " Custom Message: Only numbers are supported in 'foo'"
86
+ ]
87
+ },
88
+ {
89
+ "description" : " Custom error message for keyword failing at both top level and nested property level - type keyword" ,
90
+ "data" : {
91
+ "foo" : [1 , 2 , " text" , 3 ],
92
+ "bar" : 123
93
+ },
94
+ "valid" : false ,
95
+ "validationMessages" : [
96
+ " Custom Message: Invalid type provided" ,
97
+ " Custom Message: Only numbers are supported in 'foo'" ,
98
+ " Custom Message: Maximum 3 numbers can be given in 'foo'"
99
+ ]
100
+ }
101
+ ]
102
+ }
103
+ ]
0 commit comments